Enabling MultiPHP on DirectAdmin Print

  • 0

DirectAdmin supports multiple PHP versions, however MultiPHP support is not enabled by default. The following article will explain how to enable this feature for users on your DirectAdmin cloud compute.

How many PHP versions?

Even though there are multiple number of PHP versions out there, DirectAdmin allows us to use only 4 different PHP versions in the server at a time and provide the ability to switch between them for each domains. This can be done through the custombuild script that DirecAdmin uses.

How to check if you have Multi PHP already setup?

Step 1. Login to the DirectAdmin admin panel using https://1.2.3.4:2222 (replace 1.2.3.4 with your compute IP) as admin user

Step 2. In the left menu Control Panel Under Admin tab, select Show All Users:

Step 3: In the Users page click on the + button against the user and click on “Login as <username>”:

Step 4: You are now logged in as the user who will receive these MultiPHP changes. In the search menu search for PHP Settings and click on the PHP Settings when it pops up:



In the PHP Settings page, if you have the option to select a PHP version, you can confirm that MultiPHP is already enabled, and no further steps are required.

If you do not see an option to select a PHP Version, continue below:

Installation

Installation is done in 3 steps:

1. Setting the 4 selected PHP versions to be installed
2. Building the PHP versions
3. Building the rewrite_confs

1. Setting up the versions

Login to the server via SSH as root user and change to directory /usr/local/directadmin/custombuild:

cd /usr/local/directadmin/custombuild

From that directory run the following command:

./build update

Next setup the 4 PHP versions in following format:

./build set php1_release <php version number>
./build set php1_mode php-fpm

./build set php1_mode php-fpm has to be used because if you are going to use MuliPHP, PHP should run as php-fpm

For our example we are setting up 4 PHP versions: PHP 8.1, 8.0, 7.4 and 7.3. Run the following commands:

./build set php1_release 8.1
./build set php2_release 8.0
./build set php3_release 7.4
./build set php4_release 7.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

2. Building the PHP versions

To install PHP run the command:

./build php n

This will take time to complete as all different PHP versions has to be compiled and built. So running this in screen (or your OS equivalent of screen) is recommended

3. Building the rewrite_confs

After the PHP build completes, run the command:

./build rewrite_confs

This will complete the MultiPHP installation. Now you can login to the user account (steps shown above at top of this article) and set PHP version on the domain.

Once the installation completes the PHP settings page mentioned in this article will look like this:

From the dropdown, select the PHP version you need and click Save.


Was this answer helpful?

« Back

Ready to get started? Build your site from
$2.24/mo
GET STARTED NOW