User Tools

Site Tools


DirectAdmin's Multiple PHP Version Selection

The PHP Version Selector

DirectAdmin 1.56.0 with later CustomBuild 2.0 releases allow up to 4 php versions for users to choose from. Users will select the PHP version they desire from their Domain Setup page (note in the following image that "PHP Version Selector" in located in top-right in between the "Back" and "private_html setup" buttons.)

Clicking "PHP Version Selector" results in a pop-up box containing a drop-down listing available PHP versions from which one may choose.

Installing and Configuring PHP Versions for Use with the PHP Version Selector

These PHP versions are defined in the file /usr/local/directadmin/custombuild/options.conf like so:

  php1_release - Default PHP version used by all unless otherwise selected

The corresponding PHP handlers are defined in the custombuild options.conf as well via the php#_mode setting where # represents which either 1, 2, 3, or 4.

To check your DirectAdmin PHP versions currently installed and enabled via the options.conf, use the following command:

  grep -P 'php[\d]_' /usr/local/directadmin/custombuild/options.conf 

This will result in output similar to the following for a server running suPHP for PHP 7.3 and PHP 5.6.

  [root@host ~]# grep -P 'php[\d]_' /usr/local/directadmin/custombuild/options.conf 
  [root@host ~]# 

The DirectAdmin configuration may not have all 4 versions of PHP installed and enabled upon server provisioning depending on your host. These will be set to 'no' like below if the 3rd and 4th available PHP versions are not set:

  php3_release no
  php4_release no

If set, it will be set to the major and minor values of the version installed for that php, like so:

  php3_release 7.3
  php4_release 5.6

The following example configures all 4 of the available PHP versions as well as their PHP handlers:

  cd /usr/local/directadmin/custombuild
  ./build update
  ./build set php1_release 7.3
  ./build set php2_release 7.2
  ./build set php3_release 5.6
  ./build set php4_release 5.3
  ./build set php1_mode php-fpm
  ./build set php2_mode php-fpm
  ./build set php3_mode php-fpm
  ./build set php4_mode php-fpm
  ./build php n
  ./build rewrite_confs

You can change the version numbers and handlers around as desired for compiling your PHP versions. Note that the default PHP version is always php1_release.

Enabling the PHP Version Selector in the DirectAdmin Configuration

If you want your users to have access to the PHP selector to choose their own PHP version from the options above, you would need to make sure the php_version_selector setting is enabled in the DirectAdmin configuration. To check, run the following command:

  /usr/local/directadmin/directadmin c | grep php_version_selector

The following output would indicate that the PHP selector is available for the users:

  [root@host ~]# /usr/local/directadmin/directadmin c | grep php_version_selector
  [root@host ~]# 

The CustomBuild GUI

If you prefer to use a GUI to manage this, you can install the CustomBuild GUI Plugin. See our KH wiki for an article detailing the installation and usage of this plugin. Alternatively, you can open a support ticket with the support team and we'll be happy to install this for you! :)

control-panels/directadmin/how-to-choose-php-version.txt · Last modified: 2020/06/01 14:25 by Karson N.