cPanel: Apache Global Configuration Explained

I found this slide online which help us understanding the Apache Global Configuration which run under cPanel/WHM.

cPanel – Apache Global Configuration

cPanel: Setup Nginx as Reverse Proxy with Apache

cPanel comes with Apache web server by default. Its not mean that we cannot integrated Nginx inside. With some minor changes, we can install Nginx to listen to port 80 and forward any PHP process to Apache on another port, 88. Apache is not really good in handling static files, so we will pass this task to Nginx. You will noticed that your memory and CPU will decrease once you have done this setup.

Warning: This setting is not suitable for shared hosting environment. I strongly recommend you to apply this if you have 1 busy website running under cPanel. Make sure you have compiled your Apache modules and features using EasyApache.

I am using variables as below:

OS: CentOS 5.6 32bit
cPanel: cPanel 11.30.1 (build 4)
Domain IP:
Apache port: 88
User: mywebs
Home directory: /home/mywebs

1. Since Nginx will be reverse proxy for Apache, we don’t want our log file to record the proxy IP. We want the real IP as usual. This will make sure our stats page like Webalizer and AWstats will record the correct information. So we need to install mod_rpaf which is “Reverse Proxy Add Forward” module for Apache. You can download that at

cd /usr/local/src
tar -xzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-*
apxs -i -c -n mod_rpaf-2.0.c

2. Once installed, we need to load the module into Apache configuration. Since cPanel already has Include Editor for Apache, we will use that functions. Login to WHM > Service Configuration > Apache Configuration > Include Editor > Pre Main Include > All Versions and paste following text:

LoadModule rpaf_module modules/
RPAFenable On
RPAFproxy_ips # replace the value with your server IP
RPAFsethostname On
RPAFheader X-Real-IP

3. Click Update > Restart Apache. The module should be loaded after restart.

Continue reading “cPanel: Setup Nginx as Reverse Proxy with Apache” »

cPanel: Apache + PHP FastCGI Data Timeout Error

If you are run on cPanel server and have FastCGI enabled in Apache, you might facing following error which caused your website hang or prompting ‘500 Internal Server Error’ message. When checking into /etc/httpd/log/error_log, you will see something similar as below:

[warn] .. mod_fcgid: read data timeout in 40 seconds, ...
[error] .. Premature end of script headers: index.php ...

This is because mod_fcgid has reached the timeout in processing the parse data. So we need to increase some of the respective value:

1. Login to WHM > Apache Configuration > Include Editor > Post VirtualHost Include > All

Continue reading “cPanel: Apache + PHP FastCGI Data Timeout Error” »

PHP Handler: DSO vs CGI vs SuPHP vs FastCGI

What is PHP Handler?

PHP handler supplies the required library to interpret PHP code. Each handler delivers the libraries through different files and implementations. Each file and implementation affects Apache’s performance, because it determines how Apache serves PHP.

You need to make the right decision on how Apache should handle your websites or web applications. I am using WHM/cPanel to manage Apache and PHP, I will focus more on advantages and disadvantages from cPanel point of view rather than how to install, implement or switch between each handler.


PHP runtime is loaded once, when Apache starts up and then reused for all requests.



  • Since DSO is only loaded once, it is faster than CGI and SuPHP
  • PHP can direct access to some Apache-specific calls, which gives you some more fine-grained control on the HTTP-level.
  • Allow for most common PHP .htaccess (php_flag) directives to be used.
  • Good for single sites that require performance over ease of use and security
  • Suitable environment to run PHP optcode caching addon such as eAcclerator, APC or Xcache
  • Well suited for low and high traffic sites but not for CMS systems like Joomla


  • PHP processes are handled by the user that is running httpd. In most cases, this user is the ‘nobody’ user. This means when PHP interacts with files on the file system, they have to be accessible by the ‘nobody’ user. This creates permissions issues as your normal cPanel based user will not have access to read/write files that are owned by the ‘nobody’ user without the correct permissions changes. Most PHP web scripts need to write to files and directories and if they are owned by the cPanel user, without changing the permissions on the files or directories to 777, it will cause issues and in some cases, break your website
  • Runs not under user who owner of the site, so you will have to manually manage the permissions on a per user basis to ensure that your PHP apps/scripts can read and write to the files and directories of which it needs to function
  • Any changes on PHP configuration, will required to restart Apache service to make sure the module being reloaded


A new PHP CGI process is invoked on each Apache request for PHP processing.



Popular and Free WHM/cPanel Plugins

WHM/cPanel is the most popular Linux control panel for hosting provider. This powerful software can be integrated with many plugins which come from cPanel Inc or 3rd party provider. Integrating plugins inside WHM is easy and it will help you administering the server, while in other hand, adding more features for your users.

I have list out some of my favorite plugins including on how to install which is FREE to use:

cPanel Inc

ClamAV Connector
Description: Anti-virus protection which integrated to cPanel/WHM. You can use this to scan home directory, mail, public_html and public_ftp folder for each account

How to install: Login to WHM > cPanel > Manage Plugins > tick ‘clamavconnector’ > Save

Description: Networked resource monitoring tool that can help analyze resource trends

How to install: Login to WHM  > cPanel > Manage Plugins > tick ‘munin’ > Save

Description: Install, update, and uninstall addons. Addons in cPanel term are applications that work with cPanel to perform useful functions for users’ websites. Examples of these applications include bulletin boards, online shopping carts, and weblogs

How to install: Login to WHM > cPanel > Install cPAddons > tick all checkboxes > tick ‘Force Refresh of All cPAddon Sources’ > Update Addon Config

Ruby on Rails
Description: Open source web application framework for the Ruby programming language

How to install: Login to the server via SSH/console as root and execute following lines:


Softaculous Ltd

Description: Auto installer that can help you install 200++ web applications with single click

How to install:
cd /usr/local/cpanel/whostmgr/docroot/cgi
wget -N
chmod 755 addon_softaculous.php

Continue reading “Popular and Free WHM/cPanel Plugins” »

Move MySQL Directory to Another Location

Lets say your MySQL data has fully utilized the disk space and you have another new hard disk specifically mounted for this purpose, you will need to migrate the data over to this new location. By default, MySQL will occupied following locations in the server:

Data -/var/lib/mysql
Config – /etc
Log -/var/log

We will not migrate data in /etc or /log because it usually not required much space. I will use following variables:

Server OS: CentOS 5.6 64bit
Old MySQL data: /var/lib/mysql
New MySQL data: /mnt/disk1/mysql

Warning: You MUST able to afford downtime on MySQL service to do this!

1. First of all, we need to make sure the service is stopped (if you are running cPanel, please disable MySQL monitoring under WHM > Service Manager > Untick ‘monitor’ for MySQL):

[[email protected] ~]# service mysql stop

2. Make sure there is no MySQL services running on the server:

[[email protected] ~]# ps aux | grep mysql | egrep -v 'grep'

3. Lets copy over the data directory. We are using rsync command so we can see the copy progress with estimate time remaining (this is really good for monitoring), and also preserve the permission and ownership of the MySQL directory:

[[email protected] ~]# rsync -avpP /var/lib/mysql /mnt/disk1/mysql

4. Now we need to tell MySQL to look at new data directory. Open /etc/my.cnf via text editor and change following server options:


5. Now lets start back the MySQL with this new settings:

[[email protected] ~]# service mysql start

If everything are running back as expected, you can then delete the old /var/lib/mysql directory so you can save more free space.

cPanel – Remove FrontPage for All Accounts

FrontPage Extension in cPanel is consider deprecated and there are many security holes reported in this. Microsoft has discontinued FrontPage extension support for the Unix platform since end of 2006. It is good thing to remove this extension which sometimes being installed without your acknowledgement.

You can use many way to remove FrontPage extension, since cPanel already have built-in scripts to remove FrontPage extension which is /scripts/unsetupfp4. Following BASH script has been tested in cPanel 11.28.93 running on CentOS 5.5. It will detect users from /var/cpanel/users directory and try to search for vti directory, if found, the cPanel’s FrontPage uninstaller will execute the domain name found in .htaccess.

Lets do this. Firstly, create a new file by using text editor which, I will use nano:

[[email protected] ~]# nano /root/removefp

2. Copy and paste following scripts:

# Remove Frontpage Extension for all accounts in cPanel server
read -p "Are you sure you remove FP extension for all domains? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
u=`ls -l $USERDIR | egrep '^-' | wc -l`
for (( i=1; i<=$u; i++ ))
        user=`ls -l $USERDIR | egrep '^-' | awk {'print $9'} | head -$i | tail -1`
        echo "Checking user $user FrontPage status.."
        homedir=`cat $USERDIR/$user | grep HOMEDIRPATHS | sed 's/HOMEDIRPATHS=//'`
        if [ -d $homedir/public_html/_vti_pvt ]; then
                domain=`cat $homedir/public_html/.htaccess | grep AuthName | awk {'print $2'}`
                echo "FrontPage found. Removing FrontPage for $domain.."
                /scripts/unsetupfp4 $domain
                echo "FrontPage not found for $user"
echo "Process completed"
  exit 0

(Press ‘Ctrl-X’ then ‘Y’ then ‘Enter’ to save and exit from editor)

Continue reading “cPanel – Remove FrontPage for All Accounts” »

cPanel – Update ClamAV

If you facing below error when running clamscan especially in cPanel:

LibClamAV Warning: ***********************************************************
LibClamAV Warning: *** This version of the ClamAV engine is outdated. ***
LibClamAV Warning: *** DON'T PANIC! Read ***
LibClamAV Warning: ***********************************************************

Which means the new stable ClamAV version has been released and recommended for you to upgrade. Below is the steps need to follow:

1. Download the latest stable version of ClamAV by go to


2. Extract the download file:

tar -xzf clamav-*

3. Compile the sources:

cd clamav-*
if [ -d "/usr/lib64" ]; then libdir="--libdir=/usr/lib64" ; fi ; ./configure --prefix=/usr $libdir --sysconfdir=/etc --disable-ipv6 --disable-zlib-vcheck
make install

4. Update virus definitions:


WHM/Cpanel Logs in Details

cPanel/WHM Initial Installation Errors:
Location : /var/log/cpanel*install*
Description : These log files contain cPanel installation logs & should be referenced first for any issues resulting from new cPanel installations.


Cpanel/WHM Accounting Logs:
Location : /var/cpanel/accounting.log
Description : Contains a list of accounting functions performed through WHM, including account removal and creation.


Cpanel/WHM Service Status Logs:
Location : /var/log/chkservd.log
Description :The service monitoring demon (chkservd) logs all service checks here. Failed service are represented with a [-] and active services are represented by [+].


cPanel error logs:
Location : /usr/local/cpanel/logs/error_log
Description : cPanel logs any error it incurs here. This should be checked when you encounter errors or strange behavior in cPanel/WHM.


cPanel License Error Logs:
Location : /usr/local/cpanel/logs/license_log
Description : All license update attempts are logged here. If you run into any errors related to license when logging in, check here.


Stats Daemon Logs:
Location : /usr/local/cpanel/logs/stats_log
Description : The stats daemon (cpanellogd) logs the output from all stats generators (Awstats, Webalizer, Analog) here.


Client Information, Requested URL Logs:
Location : /usr/local/cpanel/logs/access_log
Description : General information related to access cPanel requests is logged here.


cPanel/WHM Update Logs:
Location : /var/cpanel/updatelogs/update-[TIMESTAMP].log
Description : Contains all output from each cPanel update [upcp]. It’s named with the timestamp at which the upcp process was initiated.


Bandwidth Logs:
Location : /var/cpanel/bandwidth
Description : Files contain a list of the bandwidth history for each account. Each named after their respective user.


Tailwatchd [New]:
Location : /usr/local/cpanel/logs/tailwatchd_log
Description : Logs for daemon configuired under tailwatchd ie. cPBandwd, Eximstats, Antirelayd.


Apache Logs:.

General Error and Auditing Logs:
Location : /usr/local/apache/logs/error_log
Description : All exceptions caught by httpd along with standard error output from CGI applications are logged here.
The first place you should look when httpd crashes or you incur errors when accessing website.

Continue reading “WHM/Cpanel Logs in Details” »

User Manual: cPanel + WHM in PDF

cPanel is no doubt to be well-known in the Linux hosting control panel. They have good online documentation, active communities especially in forum and also reliable on technical/sales support. But, we hardly find the documentation in PDF version which downloadable and can be print out as a book.

Here’s I share with you on the cPanel and WHM user manual. I found these some where in Internet but I cant remember which site I get it from (sorry for no credit back to the author). You can click following links to download:

cPanel_11_User_Manual – 402 KB – 189 pages

WHM_Administrator_Manual – 1.01 MB – 352 pages

Note: It is not as update as the latest version