DirectAdmin lets you change the PHP version per domain, so example.com can run PHP 8.3 while an older site on the same server stays on PHP 8.1. This guide shows where the version selector lives, how to edit php.ini values for one domain only, and how to confirm the change is live.
Before you start
You need:
- A Linux VPS running DirectAdmin, with SSH access as root or a sudo user.
- A domain already added in DirectAdmin, and either the admin login or the domain owner's login.
- The PHP versions you want already installed on the server. The selector only lists versions that exist.
Check which PHP builds are present:
ls /usr/local | grep -E '^php[0-9]+$'You will see entries such as php81, php83 or similar, depending on what CustomBuild installed (for example php74, php81, php82, php83). Each one is a full PHP build with its own PHP-FPM service, named php-fpm81, php-fpm83 and so on.
If the version you want is missing, add it in CustomBuild from SSH:
cd /usr/local/directadmin/custombuild
./build update
./build set php2_release 8.1
./build php nDirectAdmin keeps the main version in php1_release and additional versions in php2_release, php3_release and so on. Option names change between DirectAdmin releases, so check the current DirectAdmin CustomBuild documentation before you run these commands on a production server.
Warning: Adding or removing a PHP build recompiles PHP and restarts web services. Do it in a maintenance window, not during peak traffic.
Switch the PHP version per domain in DirectAdmin
- Log in to DirectAdmin at
https://203.0.113.10:2222as admin, or as the user who owns the domain. - Open Domain Setup and click the domain name, for example example.com.
- Find the PHP Version Select area. It normally shows two dropdowns, labelled PHP 1 and PHP 2.
- In the PHP 1 dropdown, pick the version that should serve web requests for this domain, for example 8.3.
- Set PHP 2 as well if it is offered. In many DirectAdmin builds this is the version used for command-line and cron jobs for that account.
- Save the form.
DirectAdmin writes a PHP-FPM pool for the domain and reloads the service, so you normally do not need to restart anything by hand. If the page reports a change but the site still answers with the old version, reload the matching service later in this guide.
The version selector applies per domain, not per user or per directory. Everything inside example.com's document root uses the version you picked unless a .user.ini or .htaccess overrides a specific setting.
Tip: Keep older PHP versions only where a site genuinely needs them. Running a version past its end of life means no security fixes from the PHP project.
Edit php.ini values per domain
- In Domain Setup, open the same domain again.
- Click PHP Settings (the label varies slightly by DirectAdmin version).
- Change the values you need, for example
memory_limit,upload_max_filesize,post_max_size,max_execution_timeanddisplay_errors. - Save. The panel writes the override for this domain only; the server-wide php.ini is untouched.
A typical set of values looks like this:
memory_limit = 512M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
display_errors = OffWarning: post_max_size must be greater than or equal to upload_max_filesize, otherwise large uploads fail silently. Set display_errors = Off on production sites and read errors from the log instead.
If your DirectAdmin version has no PHP Settings page, or you need a directive the panel does not list, use a .user.ini file in the document root. PHP-FPM reads it for the domain and its subdirectories:
cat > /home/deploy/domains/example.com/public_html/.user.ini <<'EOF'
memory_limit = 512M
upload_max_filesize = 64M
post_max_size = 64M
EOFphp.ini and .user.ini values reload on the next request once PHP's user-ini cache expires (the user_ini.cache_ttl setting, 300 seconds by default). Restarting PHP-FPM forces the change immediately.
Restart PHP-FPM and reload settings
Panel changes usually reload the pool automatically. After editing .user.ini over SSH, or when a change seems ignored, reload the service for the version you selected:
sudo systemctl restart php-fpm83
sudo systemctl status php-fpm83 --no-pager | head -n 5Expect active (running). If the service fails, the pool file for the domain has a syntax error — read the message above the status output before restarting anything else.
Warning: A failed PHP-FPM restart takes every domain using that version offline. Check nginx -t or httpd -t first if you edited web server configuration as well.
Check it works
Create a temporary info file in the domain's document root:
echo '<?php phpinfo();' > /home/deploy/domains/example.com/public_html/info.php
curl -s https://example.com/info.php | grep -m1 "PHP Version"The version in the output must match the one you selected in the panel. Confirm your php.ini value too:
curl -s https://example.com/info.php | grep -m1 "memory_limit"Then delete the file straight away:
rm /home/deploy/domains/example.com/public_html/info.phpFor a command-line check as the domain owner:
sudo -u deploy php -v
sudo -u deploy php -i | grep memory_limitAdjust the path if php is not on the user's PATH, for example /usr/local/php83/bin/php -v.
Troubleshooting
- The version you want is not in the dropdown — it is not installed. Add it in CustomBuild (
./build set php2_release 8.1followed by./build php n) and reload the Domain Setup page. - phpinfo still shows the old version — the site is served by a cached proxy or the pool was not reloaded. Clear any proxy cache in front of the domain, then restart
php-fpmXXfor the version you picked. - HTTP 503 or "File not found" after switching — the PHP-FPM pool for the domain failed to start. Run
systemctl status php-fpmXXand read the pool error log; a bad.user.inior an unsupported directive is the usual cause. - php.ini edits are ignored — a
.htaccessphp_valueline or a.user.inifile is overriding the panel value. Remove the conflicting line and reload PHP-FPM. - "Allowed memory size exhausted" after lowering the limit — the site needs more memory than you set. Raise
memory_limitand follow the memory error guide linked below.
Next steps
- Install DirectAdmin on AlmaLinux if you are still setting up the panel.
- Manage multiple PHP versions on Ubuntu with PHP-FPM for the underlying service layout.
- Tune PHP-FPM pools for your RAM so per-domain pools do not exhaust memory.
- Fix "Allowed memory size exhausted" when a site outgrows its limit.
