Skip to main content
How to change the PHP Handler in cPanel EasyApache 4

How to change PHP Handler in cPanel EasyApache 4

A PHP handler defines the method that Apache uses to communicate with your PHP scripts. By default, cPanel & WHM offers four PHP handlers – SuPHP, DSO, FastCGI and CGI. Each handler differs in its files and implementation. This affects Apache’s performance because it determines how Apache serves PHP. So, in this tutorial, we will see in detail about how each of these handlers function and how to change PHP Handler in cPanel EasyApache 4.

PHP Handlers

SuPHP

SuPHP requires mod_suphp Apache module. It offers maximum security for the scripts and runs the scripts as the owner of the script. It is technically a CGI module with high security.

The main disadvantage of suPHP is speed and CPU load. suPHP runs much slower than the other handlers, and you will see a significant increase in your overall CPU load when switched to it. It also does not support Opcode caching likeeAccelerator, APC, Memcached etc.

DSO

The DSO handler requires the MPM Prefork Apache module. PHP applications execute as the nobody user when you use the DSO PHP handler unless you use the mod_mpm_itk or mod_ruid2 Apache modules. The major benefits of DSO are speed and the ability to use opcode caching like eAccelerator, APC, Memcached etc.

FastCGI

FastCGI serves PHP applications through the mod_proxy_fcgi Apache module. This method is faster than SuPHP, but may require changes to the FastCGI directives to work efficiently. With SuExec enabled, FastCGI runs PHP scripts as the user (like SuPHP). It also provides enhanced security compared with DSO. The Main disadvantage of FastCGI is high memory usage. This is because FastCGI keeps PHP sessions opened in the background in memory for quicker access and this allows you to use an opcode caching extension such as eAcceleartor or APC with it to increase performance.

CGI

CGI stands for Common Gateway Interface. As the name implies it executes PHP applications through the mod_cgi or the mod_cgid Apache modules. It is highly configurable. However, It is also slow and insecure. Hence not recommended to use.

How to change PHP Handler in cPanel EasyApache 4

How to change PHP Handler in cPanel EasyApache 4 from WHM panel(GUI method):

cPanel EasyApache 4 provides a very cool interface to change the PHP Version and PHP Handler.

1) Move to WHM >> Home >> Software >> MultiPHP Manager >> PHP Handlersphp_handler2) Click on the edit button of the particular PHP version for which you need to change the PHP Handler. php_handler_save3) Select the proper PHP handler and Click on Apply button to save the changes.

Note: If you couldn’t find any of the PHP Handlers in the list, you can easily install it from cPanel WHM >> Home >> Software >> EasyApache 4 or via command line using “yum install module_name”.

The module details are given in the table below.

PHP HandlerModule Name
CGIea-apache24-mod_cgi or
ea-apache24-mod_cgid
FastCGIea-apache24-mod_proxy_fcgi
SuPHPea-apache24-mod_suphp
DSOea_php5x_php

 

How to change PHP Handler in cPanel EasyApache 4 from command line:

Check the current PHP configuration of your server:

You can check the current PHP configuration using the following script:

/usr/local/cpanel/bin/rebuild_phpconf --current

Sample output:

DEFAULT PHP: ea-php56
ea-php55 SAPI: suphp
ea-php56 SAPI: cgi
ea-php70 SAPI: suphp

 

Check the available PHP handlers on your cPanel server:

To check the available PHP handlers on the cPanel server, please use the option “–available”

Eg:

[[email protected] ~]# /usr/local/cpanel/bin/rebuild_phpconf --available
ea-php55: cgi none suphp
ea-php56: cgi dso none suphp
ea-php70: cgi none suphp

 

Change the PHP Handler associated with a particular PHP version:

Use the following command to change the PHP handler associated with a PHP version.

/usr/local/cpanel/bin/rebuild_phpconf --$package=$handler

Where,
$package : represents the name of the PHP package that you want to change and
$handler : represents the PHP handler that you wish to use.

Eg:

[[email protected] ~]# /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php56
ea-php55 SAPI: suphp
ea-php56 SAPI: cgi
ea-php70 SAPI: suphp

Here, the current PHP Handler associated with PHP version 5.5 is SuPHP.

We can now check the available PHP handlers on this cPanel server.

[[email protected] ~]# /usr/local/cpanel/bin/rebuild_phpconf --available
ea-php55: cgi none suphp
ea-php56: cgi dso none suphp
ea-php70: cgi none suphp

Above details shows that the other PHP handler available on the server for PHP 5.5 is CGI. So, in this example we will change the PHP handler of PHP version 5.5 from SuPHP to CGI using the command given below.

[[email protected] ~]# /usr/local/cpanel/bin/rebuild_phpconf --ea-php55=cgi

Check and verify the new PHP configuration using:

[[email protected] ~]# /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php56
ea-php55 SAPI: cgi
ea-php56 SAPI: cgi
ea-php70 SAPI: suphp

That’s it. We are done.

Conclusion:

So, in this tutorial, we have learned about the different PHP Handlers and how to change PHP Handler in cPanel EasyApache 4. If you have any queries, please feel free to contact us in the comment section.

How to change PHP Handler in cPanel EasyApache 4
4.6 (91.43%) 7 votes

GeeksAlive

TheGeeksAlive is all about Linux, Server Administration, Web Hosting and other Open Source Technologies.