Choose between modphp , suphp , cgi , fastcgi , suexec
PHP handlers are a link between a webserver(say Apache) and the PHP libraries. PHP handlers enable a webserver to load the PHP library in a certain manner and execute the PHP code and return the output to the webserver.
There are many different kind of PHP handler setups available. Each has its own advantages and disadvantages.
modphp or the Apache 2 Handler is a apache module for running PHP scripts. modphp runs PHP in a persistent manner like fastcgi. modphp runs all PHP as the Apache user or "nobody". It keeps worker processes running instead of starting and stopping PHP. There are file permission issues since files belong to the user nobody.
Opcode cache engines like APC and eAccelerator will work with mod_php since it keeps persistent workers alive.
mod_php is faster than CGI , fastCGI , and mod_suphp.
CGI runs PHP scripts as CGI module , instead of Apache module. CGI by default will run the scripts as the Apache/nobody user. However if suexec is installed then the scripts will be run as the user of the website/account. CGI is slow compared to modphp, because for every request "PHP" is started and stopped.
Opcode caching solutions will not work with CGI.
Suphp is an apache module (mod_suphp) and it also runs php scripts as CGI. suphp does not need configuration for each virtual host. It simply runs a php script with the user permissions of the owner. suphp is much slower than mod_php (upto 25 times) and even CGI. However it might be faster than suexec. suphp is easy to setup and is secure in the sense that it keeps track of which user executed the script. Since it requires little configuration it is quite popular with cPanel hostings.
Since suphp starts a PHP process upon each request, it cannot work with any opcode caching solution like APC or eAccelerator. Also suphp does not support FastCGI. It uses no resources when no pages are being requested. Ideal for low traffic websites.
Documentation : http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
mod_fastcgi is an Apache module that uses FastCGI to run the PHP scripts. FasCGI is faster than CGI and nearly as fast as modphp. It save CPU usage but uses more memory since it keeps PHP processes alive in background to process requests, instead of starting new processes.
Opcode cache engines like APC and eAccelerator can be used with fastcgi since it keeps persistent processes.
Suexec is an Apache module (mod_suexec) that allows CGI scripts to run as a particular user. Suexec needs the user to be configured for each virtual host. suexec is slower than mod_php and mod_suphp. suexec can be used with mod_fastcgi.
Modphp is ideal for moderate traffic websites, whereas suphp can be used on low traffic websites.
For high traffic websites FastCgi should be considered as it can handle multiple requests better than the rest.
suphp and fastcgi are more secure compared to modphp and plain cgi.