Archive for the ‘Cpanel’ Category

This can be done by executing the “whmapi1” command via Linux Shell. WHM API 1 accesses the WHM interface’s features. You can use this API to perform server administration tasks, administrate cPanel and WHM reseller accounts, and manage cPanel & WHM services.

You can create a temporary root WHM session by executing the following command:

bash-4.1# whmapi1 create_user_session user=root service=whostmgrd

  cp_security_token: /cpsess3485551384
  expires: ‘1492600874’
  service: whostmgrd
  session: root:b8AC4rvpcYcKo5YF:create_user_session,90f2017bccccd915920e051c2960a3d6
  command: create_user_session
  reason: Created session
  result: 1
  version: 1

This is a one-time-use session to access WHM panel. Just copy the WHM URL and paste it on web browser. This link will bypass the need to enter a root password. That’s it!


Whmapi command to create a WHM session for reseller account

To create a WHM session for a reseller account, just change the “user” name from root to reseller account’s user name. That’s it!

Same you can login to the cPanel without password by using following command:

whmapi1 create_user_session user=USER_NAME service=cpaneld



Common paths in cPanel and WHM

Posted: December 9, 2016 in Cpanel

For those users who use cPanel/WHM on their virtual or dedicated servers the following article describes common system paths and utilities.

Paths of Base Modules



/usr/local/bin/convert or /usr/bin/convert




Ruby Gems




FLV Tool

User Directories
Document Root

WWW Directory

CGI Directory

cPanel / WHM Core Directories and Files
Houses only scripts and binaries which provide installation and configuration of many cPanel services.

Houses proprietary configuration data for cPanel, including:

Primary cPanel configuration
User configurations
Reseller configurations
Accounting, conversion, and update logs
Bandwidth data
Customized service templates

The primary cPanel configuration file. Each variable within influences the way cPanel behaves, variables are line delimited, with variables separated by an equal sign. If this file does not exist cPanel falls back to defaults.

Lists each reseller with a comma-delimited list of WHM resources that reseller has access to.

Contains a list of accounting functions performed through WHM, including account removal and creation.

Files contain a list of bandwidth history for each account, each named after their respective user. History files are stored in human-readable format, while actual bandwidth data are stored in round robin databases.

File name is inherited from the feature list name. Contains a line delimited list of feature variables and a zero or one value. Variables control what cPanel resources are available to users.

Contains a list of packages named after the packages they represent. If a package belongs to reseller file name is prefixed with reseller username. Each of these values determines the value created in cPanel user file.

Contains a list of cPanel user configuration files named after the user they pertain to. Variables define account resources, themes, domains, etc.

Other /var/cpanel Directories
This directory contains logs from account copies/transfers.

Contains the output of each cPanel update executed on the server.

Named after the respective reseller users they represent, each contains only the IP address which should be used as resellers main shared IP.

Contains customized DNS zone templates created in WHM.

This directory houses a large number of scripts which serve as building blocks for many cPanel/WHM features.
These scripts can be used to:

Update cPanel and many of its services
Customize account creation routines
Perform backups of cPanel accounts
Install and update cPanel managed services

cPanel Maintenance Scripts
By default cPanel applies nightly updates at 2:13AM server time via the root crontab.
/scripts/upcp dispatches these updates using the following key components:

/scripts/updatenow – synchronizes /scripts directory
/scripts/sysup – updates cPanel managed rpms
/scripts/rpmup – updates all other system updates
Updates are logged to timestamped files in /var/cpanel/updatelogs. Update configuration is stored in /etc/cpupdate.conf

Account Management Scripts
/scripts/wwwacct (account creation)
/scripts/killacct (account termination)
/scripts/suspendacct (account suspension)
/scripts/unsuspendacct (account resuming)
/scripts/addpop (create pop account)
Updates the user:owner and user:domain tables stored in:
These tables are used to enumerate and keep track of accounts and their owners.

Package Management
Takes argument list of rpms, which are then passed to the underlying package manager.

The equivalent of ensurerpm for FreeBSD. Updates specified packages from ports.

Takes argument list of perl modules to install via CPAN. Each of the aforementioned scripts can accept an argument of ‘–force’ to force package installations.

Can be called to apply MySQL updates independent of upcp.

Will clean up the default MySQL privilege tables, by installing a more restrictive privilege schema.

Will verify that mysql is accessible with password stored in /root/.my.cnf and force a reset with a random 16 character string if inaccessible.

Can be called to apply exim updates independent of upcp.

Will rebuild exim.conf, and merge local, distribution, and cPanel configurations.

Rebuild named.conf based on existing zone files

Download, extract, and execute apache build script

Rebuilds httpd.conf based on DNS entries found in each cPanel user configuration

Other cPanel Scripts
The majority of cPanel managed service can be scripts named appropriately.

Will rebuild the PHP interpreter used internally by cpsrvd.

Will scan for and install any Perl modules required by cPanel.

Updates horde and resets the horde mysql user password.

Will attempt to rebuild quota database per information stored in /etc/quota.conf

Sometimes the cpanel script to restart tomcat /scripts/restartsrv_tomcat will not work.

For that I found directly running tomcat startup file as user root will get the tomcat working.

How to start tomcat:


How to stop tomcat:


Thats all 🙂

Note: If you want to disable it completely, you have to recompile the easyapache and uncheck the tomcat.

The Apache module mod_deflate helps in reducing the size of the information sent to a user, by compressing things prior.  It seems to work very well.  To test if your site already has mod_deflate installed and working, you can go here:


To enable mod_deflate on your WHM / cPanel server, make sure you run EasyApache through WHM, and select to install mod_deflate.  Once done, you’ll notice that it is not active globally.  In your cPanel control panel for your domain, you should notice that under “Software / Services” an icon called “Optimize Website” is now there.  This is how you control mod_deflate on a per user basis.

If however, you wish enable it globally, so that all websites on your server can benifit from this, you need to venture back into WHM, and this time go to:

Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, and select All Versions

Now, paste the following into this file, and click Update:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

That’s it, now, go back to the site I gave you at the start, load up your website, and verify that compression is now functioning.

Those who uses command line, you can achieve this my running the easy apache command line build (/scripts/easyapache), and select to include mod_deflate.  Once that is done, you can edit the “/usr/local/apache/conf/includes/post_virtualhost_2.conf” file, and paste the above code into it to achieve the same results.  Remember to restart apache once you’ve edited the file.

The following error in cPanel shows up when adding new clients that have existing name services elsewhere:

"Using nameservers with the following IPs:, Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this serversnameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver."
The reason you get this error is because you are not using the current hosting server's nameservers and A record. If you point your A record to the current server's ip it will get fix. But if the client says I want to use only remote nameservers and along with I would like to add addon domain or parked domain.

To Fix:

Logon to WHM
Select Tweak Settings under Server Setup
Click on Domains
Put checkboxes next: Allow Remote Domains
[Allow creation of parked/addon domains that resolve to other servers (e.g. domain transfers) This can be a major security problem. If you must have it enabled, be sure not to allow users to park common Internet domains.]

http://serverip/~main acct username/addondomain

For example:

How to clean mailman archives in cPanel

Posted: February 3, 2013 in Cpanel

You need to have root access to your server using SSH.
The commands required to clean the mailman archives and attachments disk space are:
1. To clean the old archives (keeping just the last 3 months):
cd /usr/local/cpanel/3rdparty/mailman/archives/private/
cd listname_clientdomain.ext
NOTE: replace listname_clientdomain.ext for your corresponding mailing list name and domain.
Then delete the files related to your list executing (as an example):
rm -fR 2009*
rm -fR 2010*
rm -fR 2011-Jan*
rm -fR 2011-Feb*
rm -fR 2011-Feb*
rm -fR 2011-Mar*
rm -fR 2011-Apr*
rm -fR 2011-May*
rm -fR 2011-Jun*
rm -fR 2011-Jul*
rm -fR 2011-Aug*
rm -fR 2011-Sep*
etc …
In the example above we deleted all the archived files for 2009, 2010 and all month until September 2011.
2. To clean the attachments (keeping just the last 3 months):
cd attachments
tmpwatch –mtime –all 744 /usr/local/cpanel/3rdparty/mailman/archives/private/listname_clientdomain.ext/attachments
NOTE: replace listname_clientdomain.ext for your corresponding mailing list name and domain.
3. To clean the cache for mailman once done the previous two steps please run:
So, you will see the right quota at the account disk space used.
That’s it.