Are you trying decide on the various PHP Handlers?
This guide will help you.
We can configure PHP in the server using different files and implementations. It is the PHP Handler that determines how PHP implement and work on the server.
The PHP handler is the specific implementation of PHP on your server that interfaces with Apache. On a cPanel server, there are four main PHP Handlers: DSO. CGI. SuPHP.
In this context, we shall look into the various PHP handlers and their pros and cons.
Why are PHP Handlers important?
A major reason for PHP being the base of a large percentage of websites is because website applications like WordPress and Joomla run on PHP.
If we have a server hosting a large number of PHP-based websites, it's better to monitor the server, its resource usage, traffic, etc, and select the most efficient handler.
The security level varies for different handlers. However, they play a major role in the server's stability, speed, and security.
Available PHP handlers are DSO, CGI, SuPHP, and FastCGI. Each handler differs in its implementation and performance.
1. Dynamic Shared Object (DSO)
Also known as mod_php, it is the default and the oldest handler. It runs PHP as an Apache module.
i. DSO is the fastest handler.
ii. CPU usage is low.
i. Security issue: While using DSO, PHP scripts will run as user nobody. Hence, if a hacker finds a vulnerability, he can modify important files. The best way to prevent such vulnerabilities is to keep the applications up to date.
ii. File Permissions: If the website provides an option to create files using PHP scripts, we will run into permission issues. The files created will be owned by nobody which will trigger permission errors.
2. Single User PHP (SuPHP)
SuPHP runs PHP as a CGI module. cPanel recommends this handler. The PHP scripts will run as the user who calls it.
i. Security: Since PHP scripts run as the user who called it, the hacker won’t get access to files outside the user’s home directory.
ii. Permissions: The files created will be under the ownership of the corresponding user. So we won't run into permission issues.
i. High CPU usage: The CPU usage of this handler high.
ii. Low speed compared to DSO.
3. Common Gateway Interface (CGI)
It is the least used handler. It runs PHP as a CGI module. PHP scripts will run as user nobody unless suEXEC is enabled. It is not so fast or secure.
It is an implementation of CGI and it runs PHP as a CGI module. It overcomes most of the disadvantages of CGI.
i. High Speed comparable to DSO.
ii. As with SuPHP, PHP scripts will run as the user, a hacker won’t be able to infect files outside the user’s home directory.
i. High memory usage: This handler has the highest memory usage. Our Support Experts don't recommend it for servers running low on memory.
ii. In addition, most of the control panels provide the option to switch the handler from the front end interface itself.