You decide to switch the webserver from Apache-only to Nginx + Apache reverse proxy on a DirectAdmin server with 200 live customer sites. CustomBuild can do this — ./build set webserver nginx_apache && ./build all d is technically the command — but running that command between cup of coffee and lunch break is how you end up with 200 customers calling at the same time because their .htaccess rewrites stopped working, their LSCache headers vanished, or the PHP handler swap broke a site pinned to a specific php-fpm socket. CustomBuild is powerful. Rebuilding the stack on a live server is a planned operation.
What’s happening
CustomBuild is DirectAdmin’s package manager for the web stack. It compiles or installs the underlying services from source or precompiled binaries: Apache, Nginx, PHP (multiple versions side by side), MariaDB/MySQL/Percona, Exim, Dovecot, ProFTPD/PureFTPD, ModSecurity. The configuration lives in /usr/local/directadmin/custombuild/options.conf, edited via ./build set <key> <value>. ./build all d rebuilds everything against the current options; smaller commands rebuild only one component (./build update_php, ./build nginx_apache, ./build exim).
The reason a stack rebuild can break sites is that customer configurations are layered on top of CustomBuild’s output:
.htaccessfiles in customer document roots assume a particular Apache + module set- Per-site PHP config in DirectAdmin’s user interface writes
php-fpmpool files that point at specific socket paths - LSCache or other caching plugins in WordPress check for specific headers and modules in the running webserver
- Cron jobs owned by customers may call
phpwith a hardcoded path to a specific version - Symlinks the customer or your support team set up to specific binaries
A rebuild that changes webserver type (Apache-only → Nginx + Apache reverse proxy), or that upgrades PHP across all customers, or that swaps PHP mode from mod_lsapi to php-fpm, changes one or more of those underpinnings. The fix isn’t “don’t rebuild” — it’s “rebuild on a staging clone first, validate against representative customer sites, then run the rebuild on production with a known rollback.”
The common rebuild scenarios:
- Webserver switch: Apache-only → Nginx + Apache (the standard production posture). Adds Nginx as a front-end reverse proxy serving static + caching + TLS termination, Apache behind on loopback for PHP.
- Add a PHP version: PHP 8.4 came out, you want to offer it as a fifth installed version alongside 8.3, 8.2, 8.1, 7.4. Doesn’t change existing sites — just adds an option.
- Remove an old PHP version: PHP 7.4 hit EOL; some customers are still pinned to it. Forcing them off 7.4 means moving each site to a supported version after compatibility testing.
- PHP mode swap: switching from
mod_lsapitophp-fpmper-site, or vice versa. Big behavior change for performance and isolation; customer-facing. - Module add/remove: enabling
mod_security, addingphp-redis, removingmod_php. Affects every customer site that depended on the now-changed module set.
How to verify
Before a rebuild, snapshot the current state and identify the customer-facing surface:
# Current CustomBuild options
cd /usr/local/directadmin/custombuild
./build show-config
./build versions
# Current Apache + Nginx modules
apache -M 2>/dev/null | sort
nginx -V 2>&1 | tr ' ' '\n' | grep -E 'module|--with'
# Current PHP versions in use
for V in 81 82 83; do
echo "=== PHP ${V} ==="
/usr/local/php${V}/bin/php -v
/usr/local/php${V}/bin/php -m | head -20
done
# Customer pinning to specific PHP versions
for U in $(ls /usr/local/directadmin/data/users/); do
cat /usr/local/directadmin/data/users/$U/domains/*.conf 2>/dev/null | grep -E '^php=' | sort -u
done | sort | uniq -c | sort -rn
# Sites with custom .htaccess complexity (>50 lines)
for U in $(ls /usr/local/directadmin/data/users/); do
find /home/$U/domains -name '.htaccess' -type f -exec wc -l {} + 2>/dev/null \
| awk '$1 > 50 {print}'
done | sort -rn | head -10
After a rebuild, the verification check is the same shape, plus actual HTTP probes against a list of representative customer sites:
# Pick 5-10 representative sites — one per package tier, one per PHP version, the largest
SITES=(largest.example.com wordpress.example.com woocommerce.example.com php74.example.com static.example.com)
for SITE in "${SITES[@]}"; do
curl -sI "https://$SITE/" | head -5
curl -sS "https://$SITE/" -o /dev/null -w "$SITE: %{http_code} | %{time_total}s\n"
done
Anything that goes from 200 to 500 is a regression caused by the rebuild. Roll back or fix.
The fix
1. Stage the rebuild
Stand up a DirectAdmin server that mirrors production: same version of DirectAdmin, same CustomBuild options pre-change, same OS version. Restore three to five representative customer accounts onto it (use DirectAdmin’s account backup/restore — Admin → User Manager → Pick user → Create Backup, then on staging → Admin → Restore Backups). Validate the staging server matches production behavior before you change anything.
Then apply the planned CustomBuild change on staging:
cd /usr/local/directadmin/custombuild
./build set webserver nginx_apache # for example
./build save
./build update
./build all d
Watch each customer site on staging — homepage, login, a known-bad rewrite path, an LSCache-protected URL, any flow that touches PHP-FPM directly. Anything that’s different on staging will be the same on production.
2. Plan the rollback before you start
Capture the current CustomBuild state to a tarball:
cd /usr/local/directadmin/custombuild
tar -czf /root/custombuild-pre-rebuild-$(date +%Y%m%d).tar.gz options.conf versions.txt
cp /etc/httpd/conf/httpd.conf /root/httpd.conf.pre-rebuild.$(date +%Y%m%d)
cp -r /etc/nginx /root/nginx.pre-rebuild.$(date +%Y%m%d) 2>/dev/null || true
If the rebuild goes wrong, the rollback is:
# Restore the options
cd /usr/local/directadmin/custombuild
cp /root/custombuild-pre-rebuild-YYYYMMDD/options.conf ./options.conf
./build all d
./build all d is the heaviest command — it rebuilds everything from scratch, takes 20-40 minutes, and is the right rollback. Most rollbacks are not needed if staging was clean. Have it documented anyway.
3. Schedule the production rebuild window
Pick a low-traffic window (early morning local time is typical). Communicate to customers that there’s a maintenance window, with a known start and a known target end. For a ./build all d, plan for 30-45 minutes of partial downtime — Apache + Nginx + PHP restart cleanly but rebuild involves transient stops.
For a less invasive rebuild (just ./build update_php to add a new version, or ./build nginx_apache to update only the webserver), the impact is shorter — a few seconds of restart for Nginx + Apache. Plan accordingly.
4. Run the production rebuild
cd /usr/local/directadmin/custombuild
./build update
./build set <key> <value> # the change you tested on staging
./build save
# For a focused rebuild
./build nginx_apache # if only switching/updating webservers
./build update_php # if updating PHP versions
./build modsecurity_ruleset # if updating WAF rules
# For a full rebuild
./build all d
Watch the output. CustomBuild logs each step; any error here means stop and assess before continuing.
After CustomBuild completes:
# Confirm services restarted cleanly
systemctl status httpd nginx php-fpm81 php-fpm82 php-fpm83
# Re-apply DirectAdmin's site configs (CustomBuild regenerates httpd.conf includes)
echo "action=rewrite&value=all" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d
The task.queue step is critical — CustomBuild rebuilds the core stack but DirectAdmin’s per-customer Apache vhosts need to be regenerated against the new template. Skipping this leaves customer sites running against stale vhost configs that reference the old webserver setup.
5. Run the verification probes
Run the same HTTP probes from the staging verification. Plus check the DirectAdmin panel:
curl -sI https://da.example.com:2222/ | head
# Should return 200 with the panel headers
If the panel is up and a sample of customer sites returns 200, the rebuild succeeded. If customer sites return 500, check /var/log/httpd/error_log and /var/log/nginx/error.log for the actual error — usually a missing module or a stale config.
6. Communicate
Send a short note to the customer list summarizing what changed: PHP version added, webserver upgraded, ModSecurity rules updated. Include the panel-facing impact (any new PHP version dropdown options, any cache header changes) so support is prepared for questions.
Specific rebuild recipes
Switch from Apache-only to Nginx + Apache reverse proxy:
cd /usr/local/directadmin/custombuild
./build set webserver nginx_apache
./build save
./build update
./build nginx_apache
echo "action=rewrite&value=all" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d
After this, every customer site is fronted by Nginx (port 80/443 public) which proxies dynamic requests to Apache (port 8080 on loopback). Static assets are served by Nginx directly. Customer .htaccess is still honored by Apache for PHP requests.
Add PHP 8.4 alongside existing versions:
cd /usr/local/directadmin/custombuild
./build set php5_release 8.4
./build set php5_mode lsapi
./build save
./build update
./build php5
Customers get a new “PHP 8.4” option in their DirectAdmin domain settings. No existing site is affected.
Remove PHP 7.4 after all customers are migrated off:
# First audit: any sites still on PHP 7.4
for U in $(ls /usr/local/directadmin/data/users/); do
grep -l 'php=74' /usr/local/directadmin/data/users/$U/domains/*.conf 2>/dev/null
done
# If non-empty, do not remove 7.4 yet. Migrate those sites first.
cd /usr/local/directadmin/custombuild
./build set php3_release no
./build save
./build php3
Wait at least 60 days after PHP X.Y’s EOL date before removing it from the stack. Customers need time to migrate code that depends on the old version.
Running a DirectAdmin server where CustomBuild changes get staged, scheduled, and rolled out without breaking sites is part of what Managed Cloud Ops handles — together with deployment management for the rebuild scheduling and rollback drills. Scope the operating cadence and we’ll plan the next major rebuild with you.