Question
There are many different PHP Handlers offered on cPanel servers. This guide will provide a basic overview of the different Handler options, and pros and cons of each one; enabling a system administrator to make an educated decision on which one to use.
Answer
mod_cgi:
- Processes will be executed as the Apache user nobody by default. If the Apache module suEXEC is installed, processes will run as the user who owns the VirtualHost instead.
- mod_cgi is considered to be one of the slower PHP handlers.
- mod_cgi is not compatible with opcode caching. This incompatibility reduces the handler's overall flexibility and prevents the use of items such as opcode cache.
- Lower overall memory footprint
mod_fcgid:
- mod_fcgid is the newer and faster version of mod_cgi
- higher overall memory footprint than mod_cgi
- Does work with opcode caching
- Processes will be executed as the user who owns the VirtualHost.
- Only one request is sent to the CGI server at a time, which means if caching is in place, there will be a much higher memory requirement as each process will have its own cache.
mod_fastcgi:
mod_fastcgi is the licensed version of mod_fcgid, so a lot of its properties will be the same such as the processes running as the user who owns the VirtualHost. However, the key difference between mod_fastcgi and mod_fcgid is that mod_fastcgi sends multiple requests to the FastCGI server at once as opposed to a single request like mod_fcgid. This difference makes it faster than mod_fcgid and reduces opcode caching systems such as APC's memory footprint by allowing concurrent PHP processes to share opcode caches.
mod_proxy_fcgi (FPM) - FastCGI process manager:
- Processes will be executed as the user who owns the VirtualHost.
- FPM is an incredibly fast PHP handler.
- Works well with opcode caching.
- Allows extreme customization on an individual and global level. (More on that here.) However, this level of customization can be confusing for users who aren't familiar with PHP-FPM.
- Can have a large memory footprint depending on the customizations made.
mod_lsapi:
- Extremely fast handler, it performs as well or better than other handlers such as PHP-FPM.
- Low memory footprint
- Processes will be executed as the user who owns the VirtualHost.
- Little to no extra configuration needed to work well
- PHP configuration changes can be placed in .htaccess files as well as php.ini files.
mod_suphp:
- Processes will be executed as the user who owns the VirtualHost.
- Added security as scripts will not run with unsafe permissions such as files over 755.
- Slower than other handlers such as mod_lsapi and PHP-FPM.
- opcode caching will work but provides no performance benefit.
mod_dso/mod_php:
- Processes run as the Apache user (Generally the 'nobody' user) rather than the VirtualHost owner/cPanel user.
- mod_dso/mod_php are not thread safe, so you must use the prefork or ITK MPM in conjunction with them.
- Can only be the handler for 1 PHP version on the server, other versions must use a different PHP handler.
- Applications that use multi-threading will cause issues and should not be used if you are using mod_dso/mod_php.
- Files or directories generated by scripts will also be owned by the Apache user, which can cause permission issues.
- PHP configuration changes can be added to .htaccess files in addition to php.ini files.
- cPanel & WHM does not support DSO with PHP 8.0 and higher