PHP as an Apache module

This mode involves enabling the mod_php module in the Apache web server settings. In this case, every web server process will include this module. This mode is especially useful for small sites with little traffic.

Advantages:

  • The fastest speed of the scripts, compared to other methods.
  • Ease of operation, the server itself processes scripts.
  • Common configuration file for all scripts (php.ini).
  • Possibility to set PHP configuration variables in web-server configuration file or by means of .htaccess file

Disadvantages:

  • All scripts run with the rights that work on the web-server, thus, if there is a need to write to any directory - you must give access rights to it to all.
  • In the case of launching third-party applications with scripts (for example, mailing), it is not possible to identify the user who launched the process.
  • Excessive load on web-server, apache busy processing scripts can be slow to give other static data.
  • Bugs in the scripts can lead to inoperability of the entire web server

PHP as CGI

This mode runs the php-cgi interpreter for all scripts that have CGI as handler. If most of the site consists of static content, CGI is a good choice, because it saves memory by allowing the interpreter to be called when needed. But at the same time, this method slows down execution, because each request will require loading the interpreter into memory.

Advantages:

  • All scripts are executed with the rights of the user - owner of the www-domain.
  • Possibility to set up PHP for each user individually.
  • Lower memory consumption compared to the apache module
  • Errors in the scripts do not cause the webserver to crash, unlike PHP mode as an apache module

Disadvantages:

  • Problems with authorization by means of PHP (means Header command) due to the fact that some server variables are not passed to the php-script.

PHP as FastCGI

In terms of its properties FastCGI is the golden mean between mod_php and CGI modes. It eliminates the disadvantages of CGI and has its advantages. When FastCGI is on, there is a process handler that is always running in the RAM of the server. This eliminates the need to start a new process at each request, as in the case of CGI. In terms of performance, FastCGI is similar to mod_php.

FastCGI combines the advantages of all of the above modes. In this case, the php-processor is started permanently and no new process has to be created for each request, which is typical for CGI mode. FastCGI is especially suitable for high-loaded sites with a constant load.

Benefits:

  • By caching some intermediate data, the script is not interpreted every time it is executed and a higher speed is achieved compared to PHP as CGI.

Disadvantages:

  • A redundant user process (php-cgi) sits in memory after the first time the process is accessed.
  • Changing the PHP mode in ISPmanager
  • PHP modes can be configured via Domains - WWW domains - Site properties - PHP, provided that all these modes are allowed for the user - the owner of the www-domain.

LSPHP

LiteSpeed PHP (LSPHP) - implemented as a mod_lsapi module on the Apache web server, and is the most efficient way to run PHP on servers running cPanel.

Advantages:

  • Increased speed of PHP scripts processing, which speeds up the entire site.
  • No 500th error in the presence of php_flag and similar directives in .htaccess. Relevant when moving from the hosting, which by default worked with mod_php.
  • Reduce resource consumption in your virtual container.
  • Improved Opcode Cache efficiency

How to install PHP modules

PHP modules can be installed through the PHP section of ISPmanager.
How to run a PHP script from the cron scheduler?

PHP scripts can be started with the cron scheduler by prefixing the script address with:
/usr/bin/php-cgi /(path...)/script.php
The PHP script can reside in any directory, i.e. it is not accessible via FTP.

Updated Oct. 16, 2018