One of the problems that web server administrators face is changing the PHP version of the DirectAdmin. We are going to teach you how to change the version of PHP used on your DirectAdmin server.
DirectAdmin 1.56.0 and later versions CustomBuild 2.0 allow users to choose from 4 PHP versions. They can select the desired PHP version from the Domain Setup page ("PHP Version Selector" is located at the top right).
Click on "PHP Version Selector" and a pop-up window will open containing a drop-down list of available PHP versions.
These PHP versions are defined in the /usr/local/directadmin/custombuild/options.conf file as follows:
php1_release - Default PHP version used by all unless otherwise selected
php2_release
php3_release
php4_release
The appropriate PHP handlers are defined in the options.conf custombuild and by the php#_mode setting where # represents any of 1, 2, 3 or 4.
To check the PHP versions currently installed and enabled in DirectAdmin through options.conf, run the following command:
grep -P 'php[\d]_' /usr/local/directadmin/custombuild/options.conf
The output of this command will be similar to:
[root@hostx ~]# grep -P 'php[\d]_' /usr/local/directadmin/custombuild/options.conf
php1_release=7.3
php1_mode=suphp
php2_release=5.6
php2_mode=suphp
php3_release=no
php4_release=no
php3_mode=php-fpm
php4_mode=php-fpm
[root@hostx ~]#
The DirectAdmin configuration may not have all 4 PHP versions installed and activated, depending on the administrator's choice.
php3_release no
php4_release no
If a PHP version is active, the chosen PHP version will be set in the /usr/local/directadmin/custombuild/options.conf file:
php3_release 7.3
php4_release 5.6
Another example configures all 4 available PHP versions as well as 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 as you wish to compile your PHP versions. Note that the default PHP version is always php1_release.
Enabling PHP Version Selector in DirectAdmin
If you want your users to have access to the PHP selector, to be able to choose their own PHP version from the options above, you need to make sure that the php_version_selector parameter is enabled in the DirectAdmin configuration. To check run the following command:
/usr/local/directadmin/directadmin c | grep php_version_selector
The following result indicates that the PHP selector is available to users:
[root@hostx ~]# /usr/local/directadmin/directadmin c | grep php_version_selector
php_version_selector=1
[root@hostx ~]#
CustomBuild GUI
If you prefer to use a GUI for management, you can install the CustomBuild GUI Plugin.
If you encounter any problems in applying the above instructions please contact us. HostX offers the fastest KVM VPS servers and can offer you specialized assistance in DirectAdmin administration.
