RemarkableCloud

PHP Version Switching in DirectAdmin

How to install multiple PHP versions in DirectAdmin using CustomBuild 2.0 and switch PHP version per domain.

DirectAdmin supports multiple simultaneous PHP versions via CustomBuild 2.0. Each domain can run a different PHP version: useful when hosting a mix of legacy and modern applications.

Installing PHP versions (server admin)

PHP versions are installed via CustomBuild on the server via SSH:

cd /usr/local/directadmin/custombuild

# See current PHP configuration
./build options | grep php

# Set PHP version slots (up to php4)
./build set php1_release 8.3
./build set php2_release 8.2
./build set php3_release 8.1
./build set php4_release 7.4   # legacy only if needed

# Set PHP mode (php-fpm recommended)
./build set php1_mode php-fpm
./build set php2_mode php-fpm

# Build and install
./build php n     # n = number of PHP versions configured
./build rewrite_confs

This takes 10-20 minutes per version. The server stays online during the build.

Switching PHP per domain (user level)

Once multiple versions are installed, users can switch PHP version for each domain:

  • Log into DirectAdmin as the user.
  • Go to Extra Features → PHP Version Selector.
  • Select the domain from the dropdown.
  • Choose the PHP version from the list of installed versions.
  • Click Save.
  • Changes take effect immediately: no restart needed.

    Checking the active PHP version

    From the domain’s document root via SSH:

    php -v
    
    # Or create a phpinfo file temporarily
    echo "<?php phpinfo();" > /home/username/public_html/info.php
    # Visit https://yourdomain.com/info.php
    # Delete it afterwards
    rm /home/username/public_html/info.php

    Customizing PHP settings per domain

    DirectAdmin allows custom php.ini values per domain via .htaccess:

    # In .htaccess (PHP-FPM mode)
    php_value memory_limit 512M
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300

    Or through the user panel: Extra Features → PHP Configuration (if enabled).

    Verifying PHP-FPM is running

    # Check PHP-FPM pools
    ps aux | grep php-fpm
    
    # Check which PHP-FPM version is running for a user
    ls /var/www/php-fpm/username/
    PHP 8.2+ is significantly faster than 7.4 and 8.0. New WordPress sites should default to 8.2 or 8.3. Only use older versions for legacy code that hasn't been updated.
    Still stuck? Ask a human, we answer in minutes.