What is Better to Choose as the Handler for PHP Scripts?

Today we would like to see one of the very popular and respond to our customers to the question: which is better? Choosing the right PHP-handler for your site will give you the optimum speed of the site that you want, and perhaps allow you to save money by using cheaper hosting package. Therefore, our article today is about it.

Which PHP handlers exist?
To run the PHP website, the server must interpret the PHP-code and generate a page at a time when visitors open your website. He interprets the code based on PHP-libraries that you are using, for example, PHP 4 or PHP 5.

There are several different handlers that can be used to download PHP: CGI, DSO, suPHP, and FastCGI. Each processor delivers library through different files and implementation. Each file and implementation affects performance Apache web server, because it determines how Apache serves PHP.

Important for the performance of the server processor is the choice that fits your situation.This selection is just as important as the version of PHP. One processor is not necessarily better than the other, it depends on your website or CMS system.

Note: You can assign a PHP handler for different versions of PHP. For example, version 5, can be treated with CGI, while PHP 4, the DSO is processed.
How can I change handler
in Cpanel it is very easy and takes only a few seconds. Sign in WHM and go to: Main >> Service Configuration >> PHP and Configuring Suexec

You simply choose your PHP handler from the drop down menu. Then click “Save”


known as mod_php. This older configuration, but, as a rule, this is the fastest processor. PHP runs as an Apache module. This means that the PHP-scripts will be executed on behalf of the Apache user, which by default is the user: «nobody».

DSO has two drawbacks. Firstly, all the files created by the PHP-script will be owned by the user «nobody». They will not be read from the Internet. Sites that you need to download files using PHP, will be faced with the problems associated with the rights to the files. This often occurs with users who ispolzyut WordPress.

Second, and in our opinion very important, disadvantage is the security issue. The created files will be «nobody» rights. Servers that use this kind of interpreter, often subjected to hacker attacks. It is important to keep track of vulnerabilities in your code, because it is the only method to protect the site from unwanted “injection”
As a rule, these problems are not greatly affect most users.
Preimuschemstvom DSO is considered low CPU usage, allowing economical use of server resources.

CGI-processor – is when running PHP as CGI-module, in contrast to the Apache module. CGI continues to handle the PHP process-like user «nobody». Usually, CGI-method is designed as a fallback when the handler for the DSO is not available. On their own documentation CPanel, this method is neither quick nor safe, regardless of whether or not Suexec enabled.

suPHP also run PHP as CGI-module. It differs from the CGI that the PHP-scripts, which are caused by the network, will be working out of the user who owns the script. suPHP, as a rule, is the default handler and is recommended for maintenance of the CPanel PHP, because you can see which users run these or other PHP scripts.

suPHP profitable that if you use file download tool on your site (for example, an automatic update or threads / install connection module for WordPress), the files will already have the right to property and the owner’s permission. Download WordPress and other functions will not operate without suPHP or FastCGI.

The main preimuschesmtovm suPHP is safety. Any PHP script that is not owned by a particular user (eg, another user) will not be executed. In addition, files that have permissions other than 644, will also be non-executable. This means that if one account is compromised, the malicious scripts can not infect other sites on your server.

The disadvantage is that suPHP uses a lot more CPU usage. In addition, you can not use the Opcode cache (eg, XCache or APC), with suPHP. If you find that your server is still constantly struggling with the CPU load, you will need to consider moving to the DSO or FastCGI.

The FastCGI
the FastCGI (otherwise: mod_fcgid) is an alternative to CGI. However, a number of advantages. It is safe and has advantages suPHP that PHP scripts will work as an actual user CPanel, unlike «nobody». The difference between FastCGI is that it can significantly save on CPU performance and provide a velocity close to the DSO. It can also be used by caching mechanisms such as Eaccelerator or the APC, which can further increase the speed of loading pages.

The main disadvantage is that FastCGI has high memory usage compared to other boot loaders.

If we consider the security needs and the benefits suPHP, and you can afford a significant increase in the use of memory, we recommend that you consider using FastCGI.


We would like to show the table that would have seen the advantages and disadvantages of each handler that we have described.

The minimum CPU usage ? ?
Minimum memory usage ? ?
Run PHP from a file’s owner ? ? ?
Security ? ?
The ability to use caching mechanisms (APC, xCache, eAccelerator)  ? ?

Standard server in the cloud with parameters 2CPU and 2GB RAM (Cloud-VPS-4) was also taken by us, for which we have installed the latest version of cPanel / WHM and set all 4 versions handler. Then we have one site with WordPress installed and conducted measurements of the performance of the site. For testing we used a utility ab with the number of simultaneous connections to 100. That’s what we’ve got:

As can be seen, the FastCGI managed the fastest, having processed over 100 requests for 15 seconds, the average is 6.5 requests per second. Therefore, we can conclude that if there is no need to save the server’s memory, you can easily switch to FastCGI or the DSO, thereby increasing the speed of loading pages. Otherwise, you should make a choice between CGI or suPHP.

Leave a Reply

Your email address will not be published. Required fields are marked *