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.

DSO

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

Architecture:

Advantages:

  • 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

Disadvantages:

  • 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

CGI

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

Architecture:

Advantages:

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:

#!/bin/bash
# Remove Frontpage Extension for all accounts in cPanel server
 
USERDIR='/var/cpanel/users'
 
read -p "Are you sure you remove FP extension for all domains? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
then
 
u=`ls -l $USERDIR | egrep '^-' | wc -l`
 
for (( i=1; i<=$u; i++ ))
do
        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
        else
                echo "FrontPage not found for $user"
        fi
done
echo "Process completed"
 
else
  exit 0
fi

(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 http://www.clamav.net/support/faq ***
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 http://www.clamav.net/download/sources

wget http://downloads.sourceforge.net/clamav/clamav-0.97.1.tar.gz
									

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
make install
									

4. Update virus definitions:

freshclam
									

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