Confused between various PHP Handlers? We can 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.
As part of our Server Management Services, we assist our customers with several PHP queries.
Today, let us focus on 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.
-
Dynamic Shared Object (DSO)
Also known as mod_php, it is the default and the oldest handler. It runs PHP as an Apache module.
Pros:
- DSO is the fastest handler.
- CPU usage is low.
Cons:
- 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.
- 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.
-
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.
Pros:
- 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.
- Permissions: The files created will be under the ownership of the corresponding user. So we won’t run into permission issues.
Cons:
- High CPU usage: The CPU usage of this handler high.
- Low speed compared to DSO.
-
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.
-
FastCGI
It is an implementation of CGI and it runs PHP as a CGI module. It overcomes most of the disadvantages of CGI.
Pros:
- High Speed comparable to DSO.
- 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.
Cons :
- High memory usage: This handler has the highest memory usage. Our Support Techs don’t recommend it for servers running low on memory.
In addition, most of the control panels provide the option to switch the handler from the front end interface itself.
[Found the article helpful? Here’s more like it]
Conclusion
In short, selecting the proper PHP handler plays a major role in the server’s stability and performance. Today, we saw pros and cons of different PHP Handlers.
0 Comments