ispmanager 6 lite, pro, host

/
/
/
Adding an alternative PHP version

Adding an alternative PHP version

Custom alternative PHP versions are not supported on CloudLinux.

If the required PHP version is not available in the ispmanager repository, you can add your own build to the control panel. To do this, define the version's packages in two XML files and install the version via the Software configuration section.

In this article, XX and X.X represent the PHP version number within package names and file paths (e.g., isp-phpXX becomes isp-php72).

Requirements for a PHP package

The control panel can work with a PHP version in all modes, provided the package is structured in the same way as ispmanager’s isp-phpXX packages—meaning all files must be located within a single directory (e.g., /opt/php72/).

FileWhat it is for
bin/php-cgiRequired. Without it, the version will not appear in the control panel
etc/php.iniRequired. The main configuration file for the version
sbin/php-fpmPHP-FPM mode. The file must be included in the PACKAGE_NAME-fpm package (e.g., isp-php72-fpm)
etc/php-fpm.dPHP-FPM mode. The control panel writes pool configurations to this directory
bin/lsphpLSAPI mode (for use with the OpenLiteSpeed or LiteSpeed web server)
etc/mods-available, etc/php.dManaging PHP extensions from the control panel

For the Apache module, the PACKAGE_NAME-mod-apache package must install a module configuration file:

  • in Debian-based operating systems: /etc/apache2/mods-available/phpXX.load
  • in RHEL-based operating systems: /etc/httpd/php-available.d/phpXX.conf

Here, phpXX refers to the package name excluding the prefix (the part before the first hyphen); for example, for isp-php72 , it would be php72.

If the package files are located in different directories, the control panel will only be able to use that PHP version in CGI mode. This is the case, for example, with packages from the Sury and Remi repositories.

How the panel detects PHP versions

Each time it starts, the control panel checks the installed primary packages (those with the parameter primary="yes") for alternative PHP versions, as defined in an XML file. For each package, the panel looks for two files:

  1. The php-cgi executable. First, the panel checks for a path specified in an entry formatted as path PACKAGE_NAME_cgi-bin within the /usr/local/mgr5/etc/ispmgr.conf file. If this entry is missing, the panel searches the package's file list for a path ending in /bin/php-cgi and records that path in the configuration file.
  2. The php.ini file. First, the panel checks for a path specified in an entry formatted as path PACKAGE_NAME_ini within the configuration file. If this entry is missing, the panel looks for an etc/php.ini file located one directory level above the bin directory (for example, if the path is /opt/phpXX/bin/php-cgi, it looks for /opt/phpXX/etc/php.ini). The panel then records this path in the configuration file.

If either of these files is missing, the PHP version will not appear in the PHP section, even though it is listed as installed under Software configuration.

Steps for adding a PHP version

To add a new alternative PHP version to the panel, log in to ispmanager with superuser rights. Then follow the steps below.

Step 1. Creating XML files

The packages must be available in the connected repositories.

  1. Go to the File manager section.
  2. Create the file /usr/local/mgr5/etc/xml/ispmgr_mod_myphp.xml with the following content:

    /usr/local/mgr5/etc/xml/ispmgr_mod_myphp.xml
    <mgrdata>
     <lang name="en">
       <messages name="feature">
         <msg name="dname_altphpXX">Alternative PHP version X.X</msg>
       </messages>
       <messages name="feature.edit">
         <msg name="package_ispphpXX">My PHP X.X</msg>
         <msg name="hint_package_ispphpXX">Use PHP X.X as CGI</msg>
         <msg name="package_ispphpXX_mod_apache">PHP X.X Apache module</msg>
         <msg name="hint_package_ispphpXX_mod_apache">Use PHP X.X as an Apache module</msg>
         <msg name="package_ispphpXX_fpm">PHP X.X for PHP-FPM</msg>
         <msg name="hint_package_ispphpXX_fpm">Use PHP X.X as PHP-FPM</msg>
         <msg name="packagegroup_altphpXXgr">PHP version X.X</msg>
         <msg name="hint_packagegroup_altphpXXgr">Use PHP X.X</msg>
         <msg name="package_ispphpXX_lsapi">PHP X.X LSAPI</msg>
         <msg name="hint_package_ispphpXX_lsapi">Use PHP X.X as LSAPI</msg>
       </messages>
     </lang>
    </mgrdata>

    The XML file will add a new item, Alternative PHP version X.X, to the table in the Software configuration section and define a separate settings form for it.

  3. If there is no ispmgr_features.d directory in /usr/local/mgr5/etc/xml/, create it. To do this, click Create and select Directory in the Type field.
  4. Create the file /usr/local/mgr5/etc/xml/ispmgr_features.d/my_php.xml. This XML file describes the PHP version packages.

    /usr/local/mgr5/etc/xml/ispmgr_features.d/my_php.xml
    <features>
      <feature name="altphpXX" featuregroup="altphp">
        <packagegroup name="altphpXXgr" type="select">
          <package name="ispphpXX" dispname="PHP X.X CGI" primary="yes" recommended="yes">
            <systemname>isp-phpXX</systemname>
          </package>
          <if value="turn_off" hide="package_ispphpXX_mod_apache" shadow="yes"/>
          <if value="turn_off" hide="package_ispphpXX_fpm" shadow="yes"/>
          <if value="turn_off" hide="package_ispphpXX_lsapi" shadow="yes"/>
        </packagegroup>
        <package name="ispphpXX_fpm" dispname="PHP X.X PHP-FPM" recommended="yes" if="nginx">
          <systemname>isp-phpXX-fpm</systemname>
        </package>
        <package name="ispphpXX_mod_apache" dispname="PHP X.X Apache module" if="apache">
          <systemname>isp-phpXX-mod-apache</systemname>
        </package>
        <package name="ispphpXX_lsapi" dispname="PHP X.X LSAPI" recommended="yes" if="lsapi">
          <systemname>isp-phpXX-lsapi</systemname>
        </package>
      </feature>
    </features>
    Details

    If the PHP-FPM, Apache module, or LSAPI packages are not being used, remove their descriptions from the file.

    CGI

    • ispphpXX — primary package description. The primary="yes" parameter is mandatory; the control panel uses it to identify the version. The <systemname> tag specifies the package name as it appears in the OS package manager.
    • isp-phpXX — package name in the package manager

    PHP-FPM

    • ispphpXX_fpm — package description
    • isp-phpXX-fpm — package name in the package manager

    Apache module

    • ispphpXX_mod_apache — package description
    • isp-phpXX-mod-apache — package name in the package manager

    LSAPI

    • ispphpXX_lsapi — package description
    • isp-phpXX-lsapi — package name in the package manager
  5. Restart the control panel.

    How to restart the control panel
    1. Go to the Shell-client section.
    2. Restart the panel with the following command:

      /usr/local/mgr5/sbin/mgrctl -m ispmgr exit
    1. Connect to the server with the ispmanager panel via SSH.
    2. Restart the panel with the following command:

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

Step 2. Installing a PHP version

Install the added PHP version via the control panel interface.

  1. Go to the Software configuration section.
  2. Locate the newly added alternative PHP version in the list.
  3. Click Software settings on the toolbar.
  4. In the PHP version X.X field, select the primary package.
  5. If necessary, select the checkboxes for other modes as well.
  6. Save your changes.
  7. Wait for the PHP version installation to complete.

Once successfully installed, the version will appear in the PHP section. If the added version is marked as installed but does not appear in the PHP section, manually update the file paths.

Step 3. Manually specifying PHP file paths

The control panel registers a version only if both the php-cgi executable and the php.ini configuration file are present. These files define the CGI mode. Other modes are supplementary; without CGI, the PHP version will not appear, even if files for other modes exist.

If the package has installed php-cgi and php.ini into directories not recognized by the control panel, specify the paths manually.

  1. Go to the File manager section.
  2. Open the control panel's configuration file: /usr/local/mgr5/etc/ispmgr.conf.
  3. Add the required lines using the following template. PACKAGE_NAME corresponds to the value of the <systemname> tag for the primary package (where primary="yes") from the my_php.xml file:

    path PACKAGE_NAME_cgi-bin PATH_TO_PHP-CGI
    path PACKAGE_NAME_ini PATH_TO_PHP.INI

    Line examples:

    Debian-based OS, packages from the sury repository. The primary package is phpX.X-cgi, not phpX.X-cli
    path phpX.X-cgi_cgi-bin /usr/bin/php-cgiX.X
    path phpX.X-cgi_ini /etc/php/X.X/cgi/php.ini
    RHEL-based OS, packages from the Remi repository. The primary package is phpXX-php-cli. The control panel will automatically detect the path to php-cgi; you only need to correct the path to php.ini
    path phpXX-php-cli_ini /etc/opt/remi/phpXX/php.ini
  4. Save the changes.
  5. Restart the control panel.

    How to restart the control panel
    1. Go to the Shell-client section.
    2. Restart the panel with the following command:

      /usr/local/mgr5/sbin/mgrctl -m ispmgr exit
    1. Connect to the server with the ispmanager panel via SSH.
    2. Restart the panel with the following command:

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

The control panel does not modify existing lines in the file. If a path is specified incorrectly, the version will not appear in the PHP section. Correct the line or delete it; the control panel will then automatically detect the correct path the next time it runs.

Step 4. Verifying the result

  1. Go to the File manager section.
  2. Open the panel log at /usr/local/mgr5/var/ispmgr.log.
  3. In the Number of rows displayed field, select 5000. The log opens in read-only mode and shows only the last lines, 50 by default.
  4. If the alternative PHP version has been successfully installed, an entry similar to the following will appear in the log:

    Sep 30 07:40:58 [2129952:1] php INFO Registering PHP module 'isp-phpXX'

    The entry is written when the control panel starts, so open the log right after the restart.

You can also find the entry in the Shell-client section with the following command:

grep "Registering PHP module" /usr/local/mgr5/var/ispmgr.log | tail

Technical details for adding a PHP version

Configuration files

FileRHEL-based operating systemsDebian-based operating systems
Panel configuration file containing paths to php-cgi and php.ini/usr/local/mgr5/etc/ispmgr.conf/usr/local/mgr5/etc/ispmgr.conf
Version names in the interface/usr/local/mgr5/etc/xml/ispmgr_mod_NAME.xml/usr/local/mgr5/etc/xml/ispmgr_mod_NAME.xml
Descriptions of version packages/usr/local/mgr5/etc/xml/ispmgr_features.d/NAME.xml/usr/local/mgr5/etc/xml/ispmgr_features.d/NAME.xml
Apache module configuration file/etc/httpd/php-available.d/phpXX.conf/etc/apache2/mods-available/phpXX.load

Log

The control panel logs information to /usr/local/mgr5/var/ispmgr.log. If a version does not appear in the PHP section, check the log for warnings containing the phrase Skip registering. For example, the message Main ini file (…) for 'isp-php72' package is missed indicates that the control panel could not locate the php.ini file.