๐ŸŸข Network Status| First month from $2.00 โ€” fully managed | Contact Support
Skip to content
Need help? Real engineers available 24/7. Average response under 15 minutes. Open a support ticket โ†’

PHP Version Switching in DirectAdmin โ€‹

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:

bash
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:

  1. Log into DirectAdmin as the user.
  2. Go to Extra Features โ†’ PHP Version Selector.
  3. Select the domain from the dropdown.
  4. Choose the PHP version from the list of installed versions.
  5. Click Save.

Changes take effect immediately โ€” no restart needed.

Checking the active PHP version โ€‹

From the domain's document root via SSH:

bash
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:

apache
# 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 โ€‹

bash
# 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/
โœ“
Use PHP 8.2 or 8.3 for new sites
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.

Managed hosting that actually manages.