Explore information related to best php handler for wordpress

PHP Handlers for your Server - Which is suitable

This article covers the pros and cons of different PHP Handlers. Basically, selecting the proper PHP handler plays a major role in the server's stability and performance. 

Apache does not natively support PHP scripts without a special module. The module that tells Apache how to handle PHP scripts is referred to as a PHP handler. 

Without a properly configured module, Apache will just send you the PHP file as a download since it doesn't know what else to do.


How does each PHP handler work and what are the pros and cons :

1. DSO/Apache Module

This is also referred to as mod_php. This module allows Apache itself to directly parse and display PHP files. PHP scripts parsed by mod_php run as the same user that Apache itself does (rather than the user account that hosts the PHP files.


Pros

i. One of the fastest handlers available.

ii. Works with mod_ruid2 or mpm_itk modules.


Cons

i. Only works with a single version of PHP on cPanel servers (you'll need to use other handers for other versions of PHP if you offer them).

ii. Scripts run as the Apache user rather than the owner of the domain or subdomain. For example, on a cPanel server, if the script creates a file or directory, that file will be owned by the user "nobody" which can cause problems when the account owner goes to backup or remove them.


2. CGI

Stands for Common Gateway Interface. Using this handler, the system will run PHP scripts as the user that owns the domain or subdomain.


Pros

Scripts run as the domain or subdomain user, not as the Apache user.


Cons

i. One of the slowest handers.

ii. Doesn't work well with PHP opcode caching.

iii. Cannot put PHP configuration changes in an .htaccess file.


3. FCGI/FastCGI

FastCGI is a variation of the CGI protocol that provides a number of benefits over the older CGI handler. Using this module, the system will run PHP scripts as the user that owns the domain or subdomain. There are some differences between mod_fastcgi and mod_fcgid, but none that are relevant to the scope of this article.


Pros

i. Scripts run as the domain or subdomain user, not as the Apache user.

ii. Very fast handler.

iii. Works with PHP opcode caching.


Cons

i. This handler uses more memory than most of the others.

ii. Cannot put PHP configuration changes in an .htaccess file.


4. PHP-FPM

FPM stands for FastCGI Process Manager. It is an improved way of implementing FastCGI processing of PHP.  Using this handler, the system will run PHP scripts as the user that owns the domain or subdomain. Each FPM pool can have independent settings.


Pros

i. Scripts run as the domain or subdomain user, not as the Apache user.

ii. One of the fastest PHP handlers.

iii. Works with PHP opcode caching.

iv. Allows for some additional level of flexibility per pool.


Cons

i. This handler can use more memory than any other handler listed here, but that depends on the number of sites using PHP-FPM and the configuration of the FPM pool.

ii. Can be somewhat more complicated to manage.

iii. Cannot put PHP configuration changes in an .htaccess file and some directives can only be changed on a global level.


5. suPHP

This handler was specifically designed to serve PHP scripts as the owner of the domain or subdomain that is executing the PHP script. On cPanel servers, it is also configured to disallow execution of files with unsafe permissions. cPanel their copy of suPHP with the latest security fixes.


Pros

i. Scripts run as the domain or subdomain user, not as the Apache user.

ii. cPanel configures suPHP so that it blocks accessing or executing any files or directories with permissions higher than 755 for security.


Cons

i. Slowest PHP handler in most cases.

ii. PHP Opcode caching has no performance improvement and only wastes memory.

iii. Cannot put PHP configuration changes in an .htaccess file.


6. LSAPI

This handler implements the LiteSpeed Web Server (LSWS) SAPI. This handler requires CloudLiunx or LSWS for the maximum benefits. Using this handler, the system will run PHP scripts as the user that owns the domain or subdomain.


Pros

i. Designed to perform as well or better than PHP-FPM under certain circumstance.

ii. Less memory use than most other handlers.

iii. Scripts run as the domain or subdomain user, not as the Apache user.

iv. No special configuration required.

v. Can read PHP values out of a .htaccess file.


Cons

i. You don't get full benefits without purchasing a third-party commercial product.

ii. Not compatible with mod_ruid2 or mpm_itk (but it shouldn't need them).

Read More