Apache no admite de forma nativa scripts PHP sin un módulo especial. El módulo que le dice a Apache cómo manejar los scripts PHP se conoce como un controlador PHP. Sin un módulo configurado correctamente, Apache simplemente le enviará el archivo PHP como descarga, ya que no sabe qué más hacer.

¿Qué controladores admiten cPanel y Plesk con Apache?

cPanelPlesk
DSO/mod_phpApache Module/mod_php
CGICGI
FCGI/FastCGIFCGI/FastCGI
PHP-FPMPHP-FPM
suPHP-- (CGI / suExec habilitado)
LSAPI-- (a menos que esté instalado LiteSpeed Web Server)

En términos generales, ¿cómo funciona cada controlador PHP y cuáles son las ventajas y desventajas de trabajar con cada uno de ellos?

Cada módulo proporciona un método diferente para analizar PHP.

DSO/Apache Module

Esto también se conoce como mod_php. Este módulo le permite a Apache analizar y mostrar directamente archivos PHP. Los scripts PHP analizados por mod_php se ejecutan como el mismo usuario que hace el propio Apache (en lugar de la cuenta de usuario que aloja los archivos PHP.

Pros

Contras

CGI

Significa Common Gateway Interface. Con este controlador, el sistema ejecutará scripts PHP como el usuario propietario del dominio o subdominio.

Pros

Contras

FCGI/FastCGI

FastCGI es una variación del protocolo CGI que proporciona una serie de beneficios sobre el controlador CGI anterior. Con este módulo, el sistema ejecutará scripts PHP como el usuario propietario del dominio o subdominio. Hay algunas diferencias entre mod_fastcgi y mod_fcgid, pero ninguna que sea relevante para el alcance de este artículo.

Pros

Contras

PHP-FPM

FPM significa FastCGI Process Manager. Es una forma mejorada de implementar el procesamiento FastCGI de PHP. Con este controlador, el sistema ejecutará scripts PHP como el usuario propietario del dominio o subdominio. Cada grupo de FPM puede tener configuraciones independientes.

Pros

Contras

suPHP

This handler was specifically designed to serve PHP scripts as the owner of the domain or subdomain that is executing the PHP script. On cPanel servers, it is also configured to disallow execution of files with unsafe permissions. cPanel their copy of suPHP with the latest security fixes.

Pros

Cons

LSAPI

This handler implements the LiteSpeed Web Server (LSWS) SAPI. This handler requires CloudLiunx or LSWS for the maximum benefits. Using this handler, the system will run PHP scripts as the user that owns the domain or subdomain.

Pros

Cons

Which PHP hander should I use?

What you should use depends on your server's resources and the types of PHP sites you need to serve. On cPanel, we recommend defaulting to suPHP, LSAPI or FCGI. On Plesk we recommend FastCGI. Once you understand how PHP-FPM works, you may want to try enabling it for at least some sites and see if it helps at all.

How do I change the PHP handler that Apache uses?

Do not change the PHP handler you are using without fully understanding what the handler will do. If you switch from a handler that does run scripts as the user to one that doesn't, or vice versa, you may need to adjust the permissions of some files or directories so that Apache can access things properly.


On cPanel, you can adjust the PHP handler in WHM by clicking on MultiPHP Manager and then select the PHP Handler tab and adjust the hander as needed.

The settings in this area of cPanel only apply if you haven't configured a site to use PHP-FPM on the main MultiPHP Manager screen.


On Plesk, navigate to Service Plans > Example plan > PHP Settings > run PHP as and select the handler you want to use.

If you have service with HostDime and you are unsure what to do about your PHP handlers, please contact us for assistance before trying to make any changes.