Enabling Multiple PHP versions On DirectAdmin
Posted on February 27th, 2017
[Updated on 08 May 2021]
It is convenient to have multiple PHPs in a server. DirectAdmin control panel has this feature available. With this, you can have legacy PHP versions to the latest stable versions. This will allow the server to support legacy software along with the latest software.
This can be achieved by using the CustomBuild tool which is the built-in tool which allows you to install, remove, and recompile programs from source. Since the installation requires the recompilation of the source code, it is advisable to take the backup of the server files. Make sure CustomBuild is updated to version 2.0.
1) Reconfiguring the CustomBuild 2.0 configuration
This can be done in two ways by directly accessing the configuration file of CustomBuild and editing the configuration file for the new configuration to take effect. The configuration file of CustomBuild is ‘options.conf’. The following commands will lead to the configuration file options.conf for editing the file.
The alternate way of doing this is to use the command line method where specific scripts are used to change the configuration files. This method is safer as unnecessary errors in configuration syntax can be avoided. Run the following commands for changing the configuration file.
2) Choosing the PHP versions
#./build set php1_mode php-fpm
#./build set php2_mode php-fpm
#./build set php1_release 7.4
#./build set php2_release 8.0
These commands allow both PHP 7.4 and PHP 8.0 on the server and php-fpm. PHP-fpm must be selected while using Nginx and Apache reverse proxy. If you are not using the reverse proxy set up, php mode can be changed. If you need to verify these changes ,you can view it in the options.conf file.
Be sure to use PHP versions above 7.3. Older versions have reached end of life and are not maintained and updated.
3) Recompiling the updated configurations
Now we have changed the configuration and need to recompile the PHP. You need to rewrite the configurations for the new configurations to take effect. The following commands will do the same.
#./build php n
Since this process can take time run these commands in screen. This prevents network failure from interrupting this process.
4) Configuring PHP versions for Websites
Now it’s time to select the PHP version for individual websites.
In order to alter the PHP version of websites navigate to the user level, select the domain name, on the right bar, you can click ‘Your Account’ >> PHP Version >> Change
If you’re facing any issues, feel free to contact our Live Chat support from https://www.interserver.net/. Our support team will be able to assist you with any service you have ordered through us.