February 21, 2020

What is PHP Handler?

PHP handlers, a type of Apache module, contain libraries that the Apache webserver uses to interpret and run PHP code. 

If you are running a PHP driven website then one of the most important things on your webserver is PHP handlers. Or you have a WordPress blog? Same thing! PHP handlers could determine properly working of your site, especially if you have huge traffic. So, what are PHP handlers? In order to publish HTML, the page webserver has to understand and translate PHP code in HTML and transfer it to the user’s browser. In that process, the server uses PHP libraries, so PHP handlers load PHP libraries to the server and determine how PHP is loaded to the server.

Different PHP handlers can be used for loading PHP: CGI, DSO, suPHP, and FastCGI. Each PHP handler has an own way of implementing PHP libraries and it determines how the server serves PHP and can hit server performance.

The /etc/apache2/conf.d/php.conf configuration file contains the global directives that configure Apache’s PHP application handlers. An include the command in the Apache configuration file (httpd.conf) loads the php.conf configuration file so that the handlers load on startup.

CGI(Common Gateway Interface) Handler

The CGI (Common Gateway Interface) defines a way for a web server to interact with external content-generating programs, which are often referred to as CGI programs or CGI scripts. It is a simple way to put dynamic content on your web site, using whatever programming language you’re most familiar with. This document will be an introduction to setting up CGI on your Apache web server and getting started writing CGI programs.

DSO (Dynamic Shared Object) Handler

Run as an Apache module, DSO also referred to as mod_php, is one of the oldest PHP handlers and its major benefits are speed and the ability to use opcode caching.

Enabling this handler you will NOT be able to use PHP Selector.

By unselecting this module you will enable back suphp as cwp default handler.

FCGI (FastCGI) Handler

FastCGI is a binary protocol for interfacing interactive programs with a web server. It is a variation on the earlier Common Gateway Interface (CGI). FastCGI’s main aim is to reduce the overhead related to interfacing between the web server and CGI programs, allowing a server to handle more web page requests per unit of time.

FCGI is a newer variation on CGI that helps to reduce the overhead associated with CGI programs, allowing a server to handle more web page requests at once.

FCGI uses persistent processes to handle a series of requests. Each individual FastCGI process can handle many requests over its lifetime, thereby avoiding the overhead of per-request process creation and termination.

suPHP (Single user PHP) Handler

suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter.

The main disadvantage of suPHP is speed and CPU load. This handler is recommended for small reseller clients because it possesses the high load of running a separate PHP process per request. Also, if the server receives a high amount of PHP requests in a small period of time, this can result in a heavy load on your server.

Because scripts run as the user, it is a common choice for sites running a CMS and doesn’t require the same changes to permissions as DSO. However, switching from DSO running as the Apache user to SuPHP would involve modifying the permissions of scripts.

Leave a Reply

Your email address will not be published. Required fields are marked *