Which PHP Handler is Best for My Server?

php handlers

PHP handlers are an everyday necessary function of your server. To run PHP files or scripts on your site, a PHP handler is needed to decipher the code inside a PHP file based on the PHP version to display the content to Internet users.

Why would you want to switch PHP handlers? It all depends on what you are trying to use your server for, whether you are looking for performance, need caching for your site(s), require a specific module enabled, and so on.

HostDime supports 5 types of PHP handlers:

  • DSO
  • SuPHP
  • CGI
  • FCGI
  • PHP-FPM

Note that SuPHP is on HostDime’s shared and reseller server environments, while the rest of the PHP handlers are allowed on our VPS and dedicated servers only.

Without further ado, let’s get into the pros and cons of each PHP handler.

Which PHP Handler is Best for My Server?

SuPHP

SuPHP works by running PHP as a CGI module on the server which separates each PHP processes under the user that is running them.

Pros:

  • Default cPanel PHP Handler.
  • PHP processes run under the user in which it is owned to.
  • Uses SuExec to run the “forked” secure PHP processes.
  • Upload tools on your site will provide the proper ownership and permissions to files and updates.
  • PHP scripts are unable to be executed unless owned to the proper user.

Cons:

  • Higher CPU usage.
  • Creates a new PHP process whenever PHP is needed to run.
  • World writeable files will be unable to be executed (Files with permissions 777).
  • No PHP Caching utility can be used (OPCache, APC, XCache, etc.).

 

DSO

This is another default handler, and is commonly considered the fastest PHP handler available. DSO runs PHP as an Apache Module, meaning PHP scripts will run as Apache’s default user “nobody” instead of the cPanel user.

Pros:

  • Considered the fastest PHP Handler.
  • Low CPU and Memory usage.
  • Option to use caching extensions.
  • You can enable Mod_Ruid2, which gives DSO high security similar to SuPHP. It creates the permissions for PHP to run as the cPanel user instead of “nobody”.

Cons:

  • Best used if you are only running one account on the server.
  • If using Mod_Ruid2, you can not use Apache Mod_userdir for temporary links to view sites (Ex: http://ServerIP/~User).
  • Easily exploitable if compromised due to permissions owned to “nobody”.
  • Auto-updates and uploading tools from WordPress or other CMS’s will fail due to permissions.
  • Used mainly with Apache and NginxCP as the main server.
  • If an account starts to abuse resources, we are unable to determine which user is causing this (Unless running Mod_ruid2 apache module).

 

CGI

CGI runs PHP as a CGI module instead of an Apache module. This PHP is not commonly used as it is considered the slowest PHP handler.

Pros:

  • The processes still run as the user “nobody”.
  • If using with SuEXEC, you can see what user has made a PHP request.

Cons:

  • Insecure.
  • High CPU usage.
  • Usually not recommended.

 

FCGI

Commonly known as FastCGI, FCGI is a higher performance version of the CGI PHP handler and is comparable to DSO.

Pros:

  • Low CPU consumption.
  • Run’s PHP processes as the cPanel user.
  • Ability to use caching extensions.
  • Very similar to the DSO handler.
  • Able to work with Nginx and non-Apache webservers.

Cons:

  • High memory consumption.
  • May encounter array of errors depending on how PHP scripts are coded.
  • PHP is running as a constant open process, rather than opening when a PHP request comes to the server.

 

FPM

FPM (FastCGI Process Manager) manages the FastCGI SAPI (Server API) in PHP, but has more configuration options than FastCGI. What’s special about FPM is it can launch more if the current load requires it.

Pros:

  • Faster than CGI-based methods like SUPHP for multi-user PHP environments.
  • Doesn’t overload a system’s memory with PHP from Apache processes.
  • Compatible with many web servers.

Cons:

  • Require changes to the FastCGI directives to work efficiently.
  • Require more configuration than mod_php.
  • Newest project, lesser known in IT

 

Changing your PHP handler would depend on which handler you want, as most are available in WHM, but some servers will need certain modules available to PHP to make the change from within WHM. If you have any questions and are a HostDime managed client, feel free to open a chat with our Support team!

[divider]

This article was written by Jared Smith with help from HostDime Support Technicians.

Leave a Reply

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