Thursday, October 2, 2008

Php Installation Differences: suphp mod_php cgi

Apache Module (mod_php)
Most administrations tools (e.g. Plesk) need mod_php in order to work properly.
Advantages:

* speed
* needs less memory (RAM) than CGI
* php.ini values can be changed via PHP scripts, vhost files, .htaccess files

Disadvantages:

* Scripts are being executed with Apache privileges, which might lead to some security related problems
* Only one version of PHP can be installed as Apache module
* It is not possible to have seperate php.ini files for every host


suPHP
PHP installation as binary and is included into Apache through suPHP
Advantages:

* Scripts will be executed with user privileges.
* Each vhost can have its own php.ini file
* Needs less memory (RAM) than CGI
* More than one PHP version can be run as suPHP
* There is no need to uninstall PHP as Apache module (mod_php)

Disadvantages:

* php.ini values cannot be changed via PHP scripts, vhost files, .htaccess files
* suPHP might be a little slower than mod_php


CGI
The PHP source will be patched and installed as binary. PHP as CGI is emplemented using suexec.
Advantages:

* Scripts will be executed with user privileges.
* More than one PHP version can be run as CGI
* Compatible with Apache module mod_vhost_alias (mass hosting module) due to our security patch
* The patch modifies PHP's open_basedir automatically

Disadvantages:

* CGI might use a little more memory (RAM). Therefore, it's not recommended to run PHP as CGI on slow virtual servers (vServer)
* php.ini values cannot be changed via PHP scripts, vhost files, .htaccess files


FastCGI
PHP will be loaded as FastCGI module into Apache webserver.
This way of implementing PHP is not very commen.
Advantages:

* Scripts will be executed with user privileges.
* More than one PHP version can be run as FastCGI
* Might be better in speed compared to CGI and suPHP

Disadvantages:

* php.ini values cannot be changed via PHP scripts, vhost files, .htaccess files
* complicated installation/configuration



CLI
PHP will be installed as CLI (CommandLineInterface) on your server.
CLI can only be used from command line.
Every other PHP installation (suPHP/mod_php/CGI) already covers CLI.

No comments: