PHP-selector

From ISPWiki
Jump to: navigation, search

In ISPmanager you can set alternative PHP versions for different PHP modes.

  • ISPmanager Lite --> "Features" --> Alternative PHP versions.
  • ISPmanager Business --> "PHP setup"

New versions will be set in the /opt/ directory.

"PHP as CGI" (and FastCGI Apache)

Make sure to set "PHP as CGI (or FastCGI Apache if your server runs Apache Prefork). It allows to choose a different version for every WWW-domain". The setting will be applied only for one WWW-domain.

Navigate to the "WWW-domains" module, select a WWW domain, click "Edit", and choose a required PHP version in the corresponding field.

PHP-versions.png

"PHP as an Apache module"

Alternative versions can be used in the "PHP as an Apache module" mode. If this option is set, the administrator in the "PHP setup" list can select a PHP version that will be used for an Apache module. This version will be set for all WWW-domains that belong to users who use PHP as an Apache module, i.e. the change will be applied to the whole server.

PHP as FastCGI (Nginx + PHP-FPM)

Alternative versions can be used in the "PHP as PHP-FPM" mode (this option is set automatically). If this option is set, every user can choose a required PHP version for the "PHP as FastCGI (Nginx + PHP-FPM)".

Switch to the User level --> "PHP setup", or return to the Admin level --> Users --> Edit. Changes are applied for all WWW-domains that belong to users, who use PHP as FastCGI (Nginx + PHP-FPM), i.e. the change will be applied to user.

Special consideration

When changing the version PHP as an Apache module, the Apache web-server is configured in such a way that the native PHP version is changed into a selected alternative version.

When changing the version PHP for PHP-FPM, a user pool is configured for PHP-FPM of a required version. The server can run multiple PHP-FPM of different versions, each version using for its own users.

How to add custom builds into the panel

Create 2 files to be able to use your PHP packages:

/usr/local/mgr5/etc/xml/ispmgr_mod_myphp.xml

<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
 <lang name="ru">
   <messages name="feature">
     <msg name="dname_altphp72">Alternative versionPHP 7.2</msg>
   </messages>
   <messages name="feature.edit">
     <msg name="package_ispphp72">My PHP 7.2</msg>
     <msg name="hint_package_ispphp72">Use PHP 7.2 as CGI</msg>
     <msg name="package_ispphp72_mod_apache">PHP as an Apache module version7.2</msg>
     <msg name="hint_package_ispphp72_mod_apache">PHP 7.2 can be used as an Apache module</msg>
     <msg name="package_ispphp72_fpm">PHP 7.2 for  PHP-FPM</msg>
     <msg name="hint_package_ispphp72_fpm">PHP 7.2 can be used as PHP-FPM</msg>
     <msg name="packagegroup_altphp72gr">PHP 7.2</msg>
     <msg name="hint_packagegroup_altphp72gr">PHP 7.2 can be used</msg>
   </messages>
 </lang>
</mgrdata>

/usr/local/mgr5/etc/xml/ispmgr_features.d/my_php.xml

<?xml version="1.0" encoding="UTF-8"?>
<features>
       <feature name="altphp72" featuregroup="altphp">
		<packagegroup name="altphp72gr" type="select">
			<package name="ispphp72" dispname="PHP 7.2 CGI" primary="yes" recommended="yes">
				<systemname>isp-php72</systemname>
			</package>
			<if value="turn_off" hide="package_ispphp72_mod_apache" shadow="yes"/>
			<if value="turn_off" hide="package_ispphp72_fpm" shadow="yes"/>
		</packagegroup>
		<package name="ispphp72_fpm" dispname="PHP 7.2 PHP-FPM" recommended="yes">
			<systemname>isp-php72-fpm</systemname>
		</package>
		<package name="ispphp72_mod_apache" dispname="PHP 7.2 Apache module">
			<systemname>isp-php72-mod-apache</systemname>
		</package>
	</feature>
</features>
<systemname>isp-php72</systemname> - the name of the  apt\yum package.
<package name="ispphp72" dispname="PHP 7.2 CGI" primary="yes" recommended="yes"> Describes the package  CGI   
<package name="ispphp72_fpm" dispname="PHP 7.2 PHP-FPM" recommended="yes"> Describes the package  PHP-FPM 
<package name="ispphp72_mod_apache" dispname="PHP 7.2 Apache module"> Describes the package for  Apache


You cannot add packages for PHP-FPM and Apache into description, if they are missing for any reason.


Restart the panel

/usr/local/mgr5/sbin/mgrctl -m ispmgr exit

In our package (named php47) the /opt/php47/etc/php.ini file must be present