How to Set Up Multiple PHP Versions in DirectAdmin Using CustomBuild 2

Priya

Content Writer & Researcher

Last Updated: 13 September 2026
How to Set Up Multiple PHP Versions in DirectAdmin Using CustomBuild 2
🖥️

Struggling to Manage Multiple PHP Versions Across Your DirectAdmin Servers?

CloudHouse Technologies specialises in expert DirectAdmin server management — from CustomBuild PHP configuration to full server optimisation. Let our team handle the technical complexity so your hosting business runs smoothly.

🖥️12,400+PCs Fixed
⭐4.9★Google Rating
⚡<15 minAvg. Response
🛡️ISO 27001Certified

If you're running a DirectAdmin server for a web hosting business, you've almost certainly hit this problem: one client's WordPress site needs PHP 7.4, another runs a modern Laravel app requiring PHP 8.2, and a third is still on a legacy PHP 5.6 application. Without proper multi-version PHP support, you're stuck choosing one version for everyone — or scrambling every time a client complains their site is broken after a PHP upgrade.

This guide walks you through how to install and manage multiple PHP versions in DirectAdmin using CustomBuild 2, the official build system that ships with DirectAdmin. You'll learn how to configure up to 4 PHP versions simultaneously, enable PHP-FPM mode for performance and isolation, and give each domain its own PHP version — all without breaking your existing sites.

What Is DirectAdmin CustomBuild 2 and Why It Matters for PHP

CustomBuild 2 is DirectAdmin's official tool for compiling and managing server software including Apache, Nginx, PHP, MySQL, and more. Unlike one-click package managers, CustomBuild compiles software directly from source with configurations tuned for DirectAdmin's environment.

For PHP management specifically, CustomBuild 2 lets you:

  • Install up to 4 PHP versions simultaneously (e.g. PHP 7.4, 8.0, 8.1, 8.2)
  • Run each version in PHP-FPM mode for better performance and process isolation
  • Allow users to assign different PHP versions per domain from their control panel
  • Upgrade or add new PHP versions without downtime on other versions

This is the standard approach for professional DirectAdmin hosting environments. Plugins like CloudLinux PHP Selector exist, but CustomBuild 2 is the built-in solution that works without additional licensing costs.

Prerequisites Before You Begin

Before you start, confirm the following:

  • Root SSH access to your DirectAdmin server
  • DirectAdmin 1.56.0 or later (run cat /usr/local/directadmin/conf/directadmin.conf | grep version to check)
  • CustomBuild 2.0 installed at /usr/local/directadmin/custombuild/
  • At least 4GB free disk space — each PHP version compiles from source and takes ~500MB–1GB
  • A compatible OS: AlmaLinux 8/9, Rocky Linux 8/9, or Ubuntu 22.04 (PHP 5.x and 7.x will NOT compile against OpenSSL 3.0+, so stick to PHP 8.1+ on modern OS versions)

Check your CustomBuild version:

cd /usr/local/directadmin/custombuild
./build version

💡 None of these worked? Skip the guesswork.

Get Expert Help →

Step-by-Step: Installing Multiple PHP Versions in DirectAdmin

1Navigate to the CustomBuild directory
cd /usr/local/directadmin/custombuild
2View current PHP configuration
./build options | grep php

This shows your current php1_release, php2_release settings and their modes (e.g. php-fpm, mod_php, fastcgi).

3Edit the options.conf file
nano /usr/local/directadmin/custombuild/options.conf

Find and set the PHP version slots. For example, to run PHP 8.1, 8.2, and 8.3 simultaneously:

php1_release=8.3
php1_mode=php-fpm

php2_release=8.2
php2_mode=php-fpm

php3_release=8.1
php3_mode=php-fpm

You can define up to 4 slots: php1_release through php4_release. The first slot (php1) is the server default.

4Save the file and build each PHP version

Build all configured PHP versions:

./build php n

The n flag means "no confirm" — it skips interactive prompts. This process will take 10–40 minutes per PHP version depending on server CPU speed. You can build a specific version slot by number:

# Build only PHP slot 2
./build php n 2
5Rewrite the Apache/Nginx configuration
./build rewrite_confs

This regenerates all virtual host config files to include PHP-FPM socket paths for each domain.

6Restart services
service php-fpm8.3 restart
service php-fpm8.2 restart
service php-fpm8.1 restart
service httpd restart
1User panel method

Log in to DirectAdmin as the domain user → Domain Setup → click the domain name → find the PHP Version Selector dropdown at the top → choose the desired PHP version → click Save.

2Admin-level method (for bulk changes)

From the admin panel, go to Admin Level → List All Users → select user → Domain Setup to change PHP version on behalf of a user.

3Command-line method
# Set domain example.com to use PHP 8.1 (slot 3)
echo "action=domain&value=php-fpm81&domain=example.com" >> /usr/local/directadmin/data/task.queue
service directadmin restart

Or use the DirectAdmin API:

curl -u admin:password "http://localhost:2222/CMD_API_DOMAIN_OWNERSHIP?domain=example.com&php=php-fpm81"

Troubleshooting Common PHP Version Issues in DirectAdmin

Problem: PHP version not appearing in the domain selector

After building a new PHP version, run ./build rewrite_confs to regenerate virtual host files. Then restart DirectAdmin: service directadmin restart.

Problem: PHP build fails with OpenSSL error

PHP 5.x, 7.x, and 8.0 cannot compile against OpenSSL 3.0 (used in AlmaLinux 9 and Ubuntu 22.04). You must use PHP 8.1 or higher on these OS versions. On AlmaLinux 8 or Rocky Linux 8, PHP 7.4+ compiles correctly against OpenSSL 1.1.x.

Problem: 500 errors after switching PHP version

Check the PHP-FPM error log for the version in question:

tail -f /var/log/php-fpm/www-error.log
# Or per-domain:
tail -f /home/username/domains/example.com/error.log

Common causes: missing PHP extensions (install via ./build php_extensions), wrong file permissions, or incompatible code for the PHP version.

Problem: Custom PHP extensions lost after rebuild

Use custom_versions.txt to persist extension settings across rebuilds:

echo "php8_extensions=ioncube_loader_lin_8.2.so" >> /usr/local/directadmin/custombuild/custom_versions.txt

Problem: php-fpm service won't start

php-fpm82 -t    # Test configuration
journalctl -u php-fpm82 --no-pager -n 50

Usually caused by a syntax error in a pool config file — check /etc/php-fpm82.d/ for recently modified files.

Performance Tips for Multi-PHP DirectAdmin Servers

Running 3–4 PHP-FPM versions simultaneously increases RAM usage. Each PHP-FPM master process uses ~30–50MB, and worker processes add ~20–30MB each. On a server with 100 domains:

  • Use ondemand or dynamic process managers in PHP-FPM pool configs to avoid idle workers wasting RAM
  • Set pm.max_children appropriately — start with 5–10 per pool and scale up based on traffic
  • Consider a managed DirectAdmin server service if you're spending more time tuning PHP than running your hosting business

Conclusion

Setting up multiple PHP versions in DirectAdmin with CustomBuild 2 is a foundational task for any professional hosting server. The process — editing options.conf, running ./build php n, and rewriting configs — takes under an hour and gives your clients the flexibility to run legacy and modern PHP applications side by side.

The key things to remember: use PHP-FPM mode for every version, stick to PHP 8.1+ on AlmaLinux 9/Ubuntu 22.04 due to OpenSSL 3.0 constraints, and always run ./build rewrite_confs after adding a new version. If you're managing this across dozens of servers or don't want to deal with CustomBuild rebuild failures, CloudHouse Technologies provides expert DirectAdmin server management so your team can focus on growing your hosting business.

Get the Free Linux Server Admin Cheatsheet (PDF)

Essential commands for server management, networking, and troubleshooting — all on one printable page.

Running Linux servers? Let us manage them for you.

Our Managed Linux Server plans cover updates, security hardening, monitoring, and 24/7 incident response — so your servers stay up and your team stays focused.

  • Proactive OS patching and security updates
  • 24×7 monitoring with instant alerting
  • Backup configuration and disaster recovery
  • Dedicated Linux engineers on call
See Pricing Plans →

What our customers say

“Our production server went down at 2 AM. CloudHouse had it back online in under 20 minutes. Incredible response time.”

Arun S.

CTO, SaaS Startup

“They migrated our entire infrastructure from Ubuntu 18 to 22 with zero downtime. Couldn't have asked for better.”

Deepak N.

DevOps Lead

Frequently Asked Questions

DirectAdmin with CustomBuild 2 supports up to 4 PHP versions simultaneously, configured via php1_release through php4_release in options.conf. Each version runs as an independent PHP-FPM service, so domains can be assigned any of the 4 available versions without conflicts.

Need this done for you?

Server Management Service

Managed Linux and Windows servers: monitoring, patching, security and 24/7 support.

Learn more

Book your free 15-minute diagnosis

A certified technician will call you back within 15 minutes during business hours.

Share this article

Leave a Comment

Comments (0)

Loading comments...