PHP interpreter modes
A comparison of PHP execution modes: mod_php, CGI, FastCGI, and LSPHP.
PHP as an Apache module (mod_php)
In this mode, mod_php is loaded directly into Apache, and every Apache process includes it. Best suited for small sites with low traffic.
Advantages:
- fastest script execution compared to other modes;
- simple setup — the server handles scripts on its own;
- a single
php.iniconfiguration file applies to all scripts; - PHP settings can be defined in the Apache config or via
.htaccess.
Disadvantages:
- all scripts run under the web server's user account, so directories that need write access must be world-writable;
- when scripts spawn external processes (e.g. mailing), it's impossible to identify which user triggered them;
- script processing adds load to Apache and can slow down static file delivery;
- errors in scripts can bring down the entire web server.
PHP as CGI
In this mode, a separate php-cgi process is launched for every request. Works well for sites that are mostly static, since the interpreter is only loaded when needed — saving RAM. The trade-off is slower execution, as a new process must be started on each request.
Advantages:
- scripts run under the domain owner's user account;
- PHP can be configured individually for each user;
- lower memory usage compared to
mod_php; - script errors don't crash the web server.
Disadvantages:
- PHP-based authentication via
Header()may not work correctly, as some server variables aren't passed to the PHP script.
Our products and services
PHP as FastCGI
FastCGI sits between mod_php and CGI — it combines the strengths of both and eliminates CGI's main drawback. A persistent handler process runs in memory, so there's no need to spawn a new process on every request. In terms of speed, FastCGI is comparable to mod_php. It's the best fit for high-traffic sites with a steady stream of requests.
Advantages:
- intermediate data is cached, so scripts aren't re-interpreted on every request — faster than CGI;
- scripts run under the domain owner's user account.
Disadvantages:
- the
php-cgiprocess stays in memory after the first request.
LSPHP
LiteSpeed PHP (LSPHP) is implemented as the mod_lsapi module for Apache and is the most performant PHP execution option on servers running cPanel.
Advantages:
- faster PHP script processing;
- no 500 errors caused by
php_flagand similar directives in.htaccess— useful when migrating from a host that ranmod_php; - lower resource consumption;
- improved Opcode Cache efficiency.
Installing PHP modules
PHP modules can be installed through the ISPmanager control panel under the PHP section.
Running a PHP script from cron
To run a PHP script via the cron scheduler, specify the full path to the interpreter before the script path:
/usr/bin/php-cgi /(path)/script.php
The script can be located in any directory, including ones that aren't accessible via FTP.
Help
If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!