Multiple PHP versions

Letting Users select between multiple different PHP versions

The release of DirectAdmin 1.56.0 allows up to 4 active PHP versions to be used, and Users can pick between them. You must be using the latest version of CustomBuild 2.0.

The first PHP version will be the default and will run all webapps. Everything else is optional.

Users can select between versions on their Domain Setup page in DirectAdmin.

The following is a sample installation of multiple PHP versions:

da build set php1_release 8.1
da build set php2_release 5.6
da build set php3_release 7.0
da build set php4_release 7.3
da build set php1_mode php-fpm
da build set php2_mode php-fpm
da build set php3_mode php-fpm
da build set php4_mode php-fpm
da build php
da build rewrite_confs

This will compile all of those PHP versions with PHP-FPM as the handler. You may change the version numbers and PHP handlers as desired.

If you need fewer than 4 PHP versions, set that given release to "no", e.g.,

da build set php4_release no
da build rewrite_confs

To use the multiple PHP version selector, one must ensure that php_version_selector is enabled (set to '1') in DirectAdmin's configuration, which it should be by default. To confirm:

da config-get php_version_selector

If this is not enabled for some reason, enable it like so:

da config-set php_version_selector 1
systemctl restart directadmin

Using a Different PHP Version for a Subdomain

You can assign a custom PHP version to a subdomain via the User DA GUI Dashboard / Sub-Domains Setup / Document Root Override in the section "PHP Version Selector".

This is implemented via the file /usr/local/directadmin/data/users/USERNAME/domains/DOMAIN.COM.subdomains.docroot.override, where where the format will extend the existing data, and allow you to add:


depending on your settings in CustomBuild options.conf.

If you set php1_select=2, for example, this will make use of the php2_release and php2_mode for this subdomain.

Contents of the file is one subdomain per line.

For example, if you have, a sample line might look like:


or if there are also public_html/private_html overrides, it might look like:


where the data after the first = character is URL encoded.

CloudLinux PHP Selector

If you're running CloudLinux and have php1_mode=lsphp, you will be able to use the CloudLinux PHP Selector plugin.

Note, that if you also use the DA PHP selector, the CloudLinux selection only has any effect if the domain is using the 1-st DA PHP instance.

Swapping all Users' PHP selection

In some cases, you might need to flip all User PHP selections to run additional version of PHP. We're using 2nd version (2) in the example, if you'd like to use 3rd or 4th as the selection - just change the number.

We would recommend you backup all /usr/local/directadmin/data/users/*/domains/*.conf files before testing this script.

#default to swap if nothing present.

for i in `ls /usr/local/directadmin/data/users/*/domains/*.conf`; do
       if ! grep -q ^php1_select $i; then
               echo php1_select=2 >> $i

       perl -pi -e "s/^php1_select=.*/php1_select=2/" $i
exit 0

Save the script, make it executable, run it, and use the following commands to follow up with a rewrite:

da build rewrite_confs
Last Updated: