What Is PHP Handler?
PHP handlers are Apache modules that contain libraries for the Apache web server to use when running PHP code. Apache’s PHP handlers are configured in the /etc/apache2/conf.d/php.conf configuration file. An include command in the Apache configuration file (httpd.conf) loads the php.conf configuration file so that the handlers load on startup.
WHM comes with six different PHP handlers. Apache handles PHP requests differently based on the files and implementation of each handler. You can also change PHP handlers in WHM as per your requirement.
Different Types of PHP Handlers
- CGI: The CGI handler executes PHP applications through the mod_cgi or the mod_cgid Apache modules. If you install the suEXEC module, the system executes PHP applications as the user that owns the VirtualHost that served the request. If you uninstall the suEXEC module, the system executes PHP applications as the nobody system user. The system provides mod_cgi and mod_ruid2 by default.
- DSO: The DSO handler embeds the PHP language inside the Apache webserver. DSO allows you to use Apache directives (for example, the php_value and php_admin_value directives). If you do not use DSO, you cannot use these directives in an .htaccess file. 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.
- FastCGI Process Manager (FPM): FastCGI serves PHP applications through the mod_proxy_fcgi Apache module. This method is fast but may require changes to the FastCGI directives to work efficiently. The FastCGI Process Manager (PHP-FPM) implementation of FastCGI includes process management, emergency restarts, and IP address restrictions.
- FCGI daemon (FCGId): FCGId serves PHP applications through the mod_fcgid Apache module. The mod_fcgid Apache module provides an alternative to the mod_cgi Apache module. FCGId launches multiple instances of a program to enable the system to handle multiple concurrent requests.
- LSAPI: LSAPI provides a fast and stable way to serve PHP applications. cPanel & WHM’s version of LSAPI differs from the one that CloudLinux provides. This version disables Checkpoint/Restore in Userspace (CRIU), connection pooling, and opcache preservation.
- suPHP: This option provides the ability to run PHP scripts as the user with the mod_suphp Apache module. This module provides a flexible and secure way to serve PHP requests.
How to Change PHP Handlers in WHM?
Method 1: From WHM
- Login into the WHM Panel as the root user.
- Under the Software section, select MultiPHP Manager.
- In the PHP Handlers section, select the PHP Handler you want against the PHP version. The system will automatically change the PHP handler once you select it from the drop-down.
Method 2: The rebuild_phpconf script
You can also change the PHP Handler by running the rebuild_phpconf script.
- Login into the server using SSH.
- Run the following command as per your requirement.
- To list current handler:
# /usr/local/cpanel/bin/rebuild_phpconf –current
- To list all available PHP handlers on the server:
# /usr/local/cpanel/bin/rebuild_phpconf –available
- To change the current PHP handler to “DSO”:
# /usr/local/cpanel/bin/rebuild_phpconf 4 dso none 1
- To change the current PHP handler to “SuPHP”:
# /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1
- To change the current PHP handler to CGI:
# /usr/local/cpanel/bin/rebuild_phpconf 5 none cgi 1
- To change the current PHP handler to FastCGI:
# /usr/local/cpanel/bin/rebuild_phpconf 5 none fcgi 1
Example: If you wish to change the PHP Handler for PHP 7.4 (ea-php74) to suPHP, run the following command:
If you enjoyed this tutorial, then you would love our support! All Kemuhost hosting plans include 24/7 support from our amazing support team. Check out our web hosting plans and have your website migrated for free today!