In ISPmanager you can enable PHP-scripts for a website. To do so, enable the PHP option and enter its parameters when creating or editing a WWW-domain. Learn more in Add a WWW-domain.

Supported  PHP modes:

  • Apache module;
  • LSAPI;
  • CGI;
  • FastCGI (Apache);
  • FastCGI (Nginx + PHP-FPM).

For more information about PHP features in different modes please refer to the article PHP settings on CloudLinux.

Apache module


Peculiarities:

  • dynamic content is handled by the PHP module of the Apache web-server;
  • PHP parameters are set globally for all WWW-domains of the users with this mode. Only an administrator can modify the settings in Web-server settings → PHP → Extended settings;
  • you can select only one PHP version that will be applied to all ISPmanager users; 
  • this mode is not as fast as  "LSAPI" and "FastCGI (Nginx + PHP-FPM)", but is faster than "CGI" and "FastCGI (Apache)".

Perform the following operations to activate the module:

  1. Go to Accounts  → Users  → Edit enable the option PHP as Apache module.
  2. Select the mode when creating or editing the WWW-domain. Learn more under Add a WWW-domain.

The Apache configuration file of the WWW-domain looks like the following: 

Apache configuration file

<FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
<IfModule php5_module>
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f <administrator email>"
    php_admin_value upload_tmp_dir "/var/www/www-root/data/mod-tmp"
    php_admin_value session.save_path "/var/www/www-root/data/mod-tmp"
    php_admin_value open_basedir "/var/www/www-root/data:."
</IfModule>
<IfModule php7_module>
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f <administrator email>"
    php_admin_value upload_tmp_dir "/var/www/www-root/data/mod-tmp"
    php_admin_value session.save_path "/var/www/www-root/data/mod-tmp"
    php_admin_value open_basedir "/var/www/www-root/data:."
</IfModule>

<IfModule php5_module>
    php_admin_flag engine on
</IfModule>
<IfModule php7_module>
    php_admin_flag engine on
</IfModule>
BASH

LSAPI


Peculiarities:

  • dynamic content is handled by the LSAPI module of the Apache web-server;
  • PHP parameters are set for every user. A user can modify the settings in WWW → PHP → Extended settings;
  • you can select any PHP version from the list of installed alternative versions for every WWW-domain that uses this mode. The native PHP version is used for the module itself; 
  • one of the fasted Apache mode. The fastest one is "FastCGI (Nginx + PHP-FPM)".

Perform the following operations to activate the module:

  1. Select Prefork for Apache. Learn more under Install a web-server.
  2. Go to Accounts  → Users  → Edit  and enable the option PHP as LSAPI for Apache and Enable CageFS.
  3. Select the mode when creating or editing the WWW-domain. Learn more under Add a WWW-domain.

The Apache configuration file of the WWW-domain looks like the following: 

Apache configuration file

<FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler application/x-lsphp72
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
<IfModule lsapi_module>
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f <administartor email>"
    php_admin_value upload_tmp_dir "/var/www/testa/data/mod-tmp"
    php_admin_value session.save_path "/var/www/testa/data/mod-tmp"
    php_admin_value open_basedir "/var/www/testa/data:."
</IfModule>
BASH

CGI


Peculiarities:

  • dynamic content is handled by Apache as CGI;
  • PHP parameters are set for every user. A user can modify the settings in WWW → PHP → Extended settings;
  • you can select only one PHP version that will be applied to all ISPmanager users;
  • the slowest mode.

Perform the following operations to activate the module:

  1. Go to Accounts  → Users  → Edit enable the option PHP as CGI and Enable , select the PHP version.
  2. Select the mode when creating or editing the WWW-domain. Learn more under Add a WWW-domain.

The Apache configuration file of the WWW-domain:

Apache configuration file

<FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler application/x-httpd-php5
</FilesMatch>
ScriptAlias /php-bin/ /var/www/php-bin-isp-php52/<WWW-domain owner>/
AddHandler application/x-httpd-php5 .php .php3 .php4 .php5 .phtml
Action application/x-httpd-php5 /php-bin/php
BASH

FastCGI (Apache)


Peculiarities:

  • dynamic content is handled by Apache as FastCGI;
  • PHP parameters are set for every user. A user can modify the settings in WWW → PHP → Extended settings;
  • you can select a PHP version for every WWW-domain that uses this mode; 
  • a faster mode that "CGI', but slower than  "Apache module", "LSAPI", and"FastCGI (Nginx + PHP-FPM)". 

Perform the following operations to activate the module:

  1. Install Apache MPM-Prefork and the PHP module. Learn more under Install a web-server.
  2. Go to Accounts  → Users  → Edit enable the option PHP as  FastCGI (Apache).
  3. Select the mode when creating or editing the WWW-domain. Learn more under Add a WWW-domain.

The Apache configuration file of the WWW-domain:

Apache configuration file

<FilesMatch "\.ph(p[3-5]?|tml)$">
    SetHandler fcgid-script
    FCGIWrapper /var/www/php-bin/<WWW-domain owner>/php
</FilesMatch>

Options +ExecCGI
BASH

FastCGI (Nginx + PHP-FPM)


Peculiarities:

  • dynamic content is handled by PHP-FPM;
  • PHP parameters are set for every user. A user can modify the settings in WWW → PHP → Extended settings;
  • PHP-FPM doesn't support .htaccess rules;
  • the fastest mode. 

Perform the following operations to use the module:

  1. Go to Accounts  → Users  → Edit enable the option PHP as FastCGI (Nginx + PHP-FPM).
  2. Select the mode when creating or editing the WWW-domain. Learn more under Add a WWW-domain

The Nginx configuration file of the WWW-domain:

Nginx configuration file

location @php {
    fastcgi_index index.php;
    fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f <administrator email>";
    fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
    fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    try_files $uri =404;
    include fastcgi_params;
BASH