Search Our Database
How to Install PHP Selector and Upgrade PHP Version on DirectAdmin CustomBuild 2.0 in AlmaLinux or Rocky Linux
Introduction
As CentOS 7 reached its End of Life (EOL) on June 30, 2024, many system administrators and hosting providers have migrated to its downstream alternatives, such as AlmaLinux and Rocky Linux. These Enterprise Linux (EL) clones are binary-compatible with Red Hat Enterprise Linux (RHEL), making them ideal drop-in replacements for CentOS in server environments. This change has significant implications for control panels like DirectAdmin, which rely on system stability, compatibility, and long-term support.
One of the essential features in DirectAdmin is PHP Selector, provided via CustomBuild 2.0, which allows administrators to easily install and switch between multiple PHP versions per user account. This is particularly critical in shared hosting environments where different applications may require different PHP versions for compatibility and security purposes.
This guide provides detailed instructions on installing PHP Selector and upgrading the PHP version using DirectAdmin’s CustomBuild 2.0 on an AlmaLinux or Rocky Linux system. It assumes a clean or existing DirectAdmin installation on a supported version of these operating systems. The guide applies to AlmaLinux 8/9 and Rocky Linux 8/9, which are both fully supported by DirectAdmin as of the latest builds.
Key use cases include:
- Hosting multiple web applications that require different PHP versions.
- Maintaining security by using the latest PHP releases.
- Avoiding software conflicts through isolated PHP environments per user.
This article will cover the full setup process, from enabling PHP Selector to setting custom versions per user. Challenges may arise if system dependencies are missing or if conflicting repositories are used, so this guide includes specific configuration tips to avoid such issues. It assumes the use of the CustomBuild 2.0 tool, which is required for PHP Selector functionality in DirectAdmin.
Prerequisites
- A server running AlmaLinux 8/9 or Rocky Linux 8/9.
- DirectAdmin control panel installed with root or sudo access.
- CustomBuild 2.0 is installed and enabled.
- At least 2 GB of RAM and 2 vCPU cores (recommended for compiling PHP versions).
- gcc, make, wget, and tar installed.
- A static IP address configured for the server.
Step-by-step Guide
Step 1: Verify CustomBuild 2.0 is Enabled
Check that CustomBuild 2.0 is in use by running:
cd /usr/local/directadmin/custombuild ./build version
If not using CustomBuild 2.0, upgrade it:
cd /usr/local/directadmin mv custombuild custombuild.bak wget -O custombuild.tar.gz https://files.directadmin.com/services/custombuild/2.0/custombuild.tar.gz tar xvzf custombuild.tar.gz cd custombuild ./build
Step 2: Enable PHP Selector
Edit the option.conf file to allow multiple PHP versions:
vi /usr/local/directadmin/custombuild/options.conf
Here’s a clean and minimal example for using 4 PHP versions, with the rest disabled:
# PHP Settings php1_release=8.1 php1_mode=php-fpm php2_release=8.3 php3_release=8.2 php4_release=8.0 php5_release=no php6_release=no php7_release=no php8_release=no php9_release=no
Step 3: Install PHP Versions
Build and install the selected PHP versions:
cd /usr/local/directadmin/custombuild ./build update ./build php n
To compile and install a single PHP version, use php_expert syntax:
cd /usr/local/directadmin/custombuild ./build php_expert 8.2 php-fpm
Step 4: Enable PHP Selector in DirectAdmin
Once all desired PHP versions are built, run the following to update the server config:
./build rewrite_confs
Step 5: Verify PHP Versions in DirectAdmin
Log into DirectAdmin as a user or admin, then go to:
User Level → Domain Setup → PHP Version Selector
Each domain should now be able to select from the installed PHP versions. Only the versions defined in phpX_release and built will appear.
To verify via CLI:
To check per domain, create a phpinfo.php file:
Then access: http://example.com/phpinfo.php
Conclusion
By following the steps in this guide, DirectAdmin users on AlmaLinux or Rocky Linux systems can successfully install and configure multiple PHP versions using CustomBuild 2.0. This enables flexible PHP version management across different domains and users, ensuring compatibility and security across hosted applications.
Should you have any inquiries about the guidelines, please feel free to open a ticket through your portal account or contact us at support@ipserverone.com. We’ll be happy to assist you further.


