cPanel - Guide e configurazione search
clear

Handler PHP: functioning, use and installation

A Handler PHP is the software module allowing Apache libraries to interpret the website's PHP code, affecting performances, permissions and  level of security (it's the handler to decide what "it's allowed  or not allowed") and generation of pages (dynamic).

The Handler PHP sets how the language has to be upload on the server where it has to work. There are several handlers that can be used, such as CGI, DSO, suPHP and FastCGI and  any of them realizes the libraries behavior, using implementations and distinct files.

It's easy to see how the handlers can affect the charge of work and the performances of servers considerably: so, it's important to choose them in the wisest way possibile.

It's essential to understand that no handler is better than the others: each one has its own characteristic and your choice depends on your specific needs.


By default, cPanel & WHM offers six PHP handlers. Each handler differs in files and implementation, which affects the speed and security with which Apache handles PHP requests.

Changing your cPanel's PHP handler is pretty simple.

First of all, log into your WHM account and go to Home >> Software >> MultiPHP Management.

In the "PHP Managers" tab click "Edit" on the version of php where you want to enable a particular handler and click "Apply" to make the changes.


 

If the desired handler is not in the list, use “Easy Apache” to compile it and make it available.

  1. Go to the Software >> EasyApache 4 section



  2. Click on "Customize" under "Currently Installed Packages"




  3. Click on “Apache Modules” and choose the handlers you want to install / enable.

As we said before, there are several handlers PHP. Here is a short list of the most popular ones.


DSO (Dynamic Shared Object)

It's usually known as mod_php. It's one of the eldest handler but, at same time, one of the most performing one. It makes PHP works as module for the Apache server and this means that the PHP instructions are processed by the Apache user "nobody".

There are two main drawbacks for DSO. First of all, PHP files are considered a property of the user so, if the website requires upload functionalities, they cannot be guaranteed (it will be necessary to set permissions with CHMOD).
For example, the images and files uploading functions in WordPress, cannot work with a DSO handler, so the automatic updates.

The second drawback is related to the security of the system. Considering that the files are a property of the Apache user "nobody", if a hacker finds out a fail in the PHP script, he/she could create his/her own file with high privileges, being able to manipolate the filesystem contents from the outside.
This makes DSO inappropriate for multi-users configurations, such as reseller account and shared hosting. At the opposite, in case of a single user active on the machine -as in the case of a dedicated hosting-, you can benefit of the module speed and efficiency.

The easiest way to avoid any risk stands in updating the software constantly, keeping up to CMS updates or planning them with your webmaster or developer.

The DSO efficiency stands in its basic use of CPU, that makes it widely used on the main part of servers as a default choice.


CGI (Common Gateway Interface)

It's one of the most popular handler and it makes PHP work as CGI module instead of Apache. Otherwise, it also execute PHP processes as Apache "nobody" user, but keeping the users processing several requests using the module suEXEC under control. According to cPanel documentation, this module is neither efficient nor secure, even if it's possibile to make the additional system component intervene. 

cPanel & WHM provides mod_cgi and mod_ruid2 by default.


suPHP (Single user PHP)

It makes PHP work as CGI module but with an important difference. The script processed by the web, in fact, only works for the same user owning the suPHP rights: that's the reason why it's the official suggested module by cPanel, because it allows to monitor constantly which user is operating, instead of generically referring to the "nobody" user.
suPHP allows, furthermore, to get over the limitations we've previously described, concerning the upload of the website's files - automatic updates, plugin installation or WordPress themes - that can be executed in high-security conditions. It's important to say that the upload functions cannot work on a server without suPHP or FastCGI.

The suPHP handler provides two important advantages: any script can be exclusively executed only by the owner and the files owning writing permissions cannot be, in general, executable.
In other terms, if a hosting account is compromised it won't be able to damage or "infect" other hosting accounts.

The only real suPHP disadvantage stands in the massive use of the server's CPU, causing system slowdowns. Furthermore, it's not allowed to use Opcode Cache (such as Xcache or APC), forcing the admin to install an additional plugin.


Fast CGI 

It's an alteration of the CGI module, improving server performances and security aspects. It combines the PHP advantages and allows the script execution only for the owner. The main difference of FastCGI, compared to other handlers, is providing an optimized use of the CPU, in addition to high performances comparable with DSO ones. This module is compatible with Accelerator or APC, which can increase the speed in visualizing images.

The disadvantage of this handler stands in the use of RAM memory: this happens because the PHP processes are not dynamically managed at each command, considering the presence of a single active session in background. This handler also allows the use of plugin such as Opcode for the cache.

You have to consider the opportunity to use FastCGI in case you want to take advantage of the best characteristics of PHP and, at the same time, of an optimized use of RAM memory.


FastCGI Process Manager (FPM)

PHP FastCGI Process Manager (PHP-FPM) is an alternative FastCGI daemon for PHP that allows a website to handle heavy loads. PHP-FPM maintains pools (workers that can respond to PHP requests) to accomplish this. PHP-FPM is faster than traditional CGI-based methods, such as SUPHP, for multi-user PHP environments.

You can change the FPM settings from WHM following this procedure: Home -> Software -> MultiPHP Management and then clicking on the "System PHP-FPM Manager" tab.

 

FCGI daemon (FCGId)

mod_fcgid is a high-performance alternative to mod_cgi or mod_cgid, which starts a sufficient number of instances of the CGI program to handle concurrent requests, and these programs remain running to handle additional incoming requests. It is preferred by PHP developers, for example, as an alternative to running mod_php in-process, offering very similar performance.

We recommend the mod_fcgid Apache module only for advanced system administrators who understand how to modify the performance of the mod_fcgid Apache module.


LSAPI 

Apache mod_lsapi is a LiteSpeed ​​Technologies API based module for PHP. It offers excellent PHP performance, a small memory footprint coupled with great security and opcode caching support. Using LSAPI, we have seen higher Apache performance with mod_php, easier installation of php-fpm, and easier integration with any control panel. LSAPI means faster and more stable dynamic web pages.

To use the full functionality of this manager, your system must be running CloudLinux.


Here is a comparing table of all the handlers described above. 

 

 

DSO

CGI

SuPHP

FastCGI

Low CPU use

   

Low RAM use

 

Use PHP as process owner user (not as Apache shared user)

 

only with suEXEC

Security

   

 

Did you find this answer helpful?

Still need help?

Contacts

Contacts

Request information, assistance or quotes

Chat

Chat

Ask about services and promotions

Ticket

Ticket

Submit a request for technical support

Payments

Payments

Make a payment in a few clicks