Skip to content

Apache returning 503 on every PHP request after an EasyApache 4 rebuild

How to diagnose Apache returning 503 for every PHP request on a cPanel server after an EasyApache 4 PHP rebuild — usually a PHP-FPM service that did not restart or a stale socket reference in the vhost config.

Right after a clean EasyApache 4 provision that touched PHP, every PHP request returns 503 Service Unavailable. Static files are fine. Apache itself is running. The cause is almost always that one of the PHP-FPM services either did not restart cleanly or is listening on a different socket than the one Apache’s vhost configs are now pointing at. The fix is mechanical once you know where to look.

What’s happening

When EA4 provisions a new PHP version or modifies an existing one, it regenerates the per-account PHP-FPM pool configs and the Apache vhost includes that proxy to them. The chain that has to hold: FPM service starts, pool sockets get created at /opt/cpanel/ea-php<ver>/root/usr/var/run/php-fpm/<user>.sock, Apache’s vhost config has a ProxyPass line pointing at exactly that path. If any link breaks — FPM service refuses to start because of a syntax error in a pool, socket path differs between FPM and Apache — every PHP request fails with 503.

How to verify

Walk the chain from Apache to FPM:

systemctl status ea-php82-php-fpm
ls /opt/cpanel/ea-php82/root/usr/var/run/php-fpm/
apachectl -t -D DUMP_INCLUDES | grep -A2 ProxyPassMatch | head
grep -r "ProxyPass\|Unix:" /etc/apache2/conf.d/userdata/std/2_4/<user>/ 2>/dev/null
tail /opt/cpanel/ea-php82/root/usr/var/log/php-fpm.log

The FPM service status tells you if the daemon is alive. The socket listing tells you if it actually created sockets. The Apache include shows what Apache is trying to connect to.

The fix

  1. Start with the FPM service. If systemctl status ea-php82-php-fpm is not active, that is the entire problem. journalctl -u ea-php82-php-fpm --since "30 min ago" | tail -30 shows why; common causes are pool config syntax errors and missing user accounts.
  2. If the FPM service refuses to start because of a pool error: the offending pool file is in /opt/cpanel/ea-php82/root/etc/php-fpm.d/. The journal line points to the file. Either fix it or temporarily rename it to .disabled and start FPM without that pool.
  3. If FPM is running but sockets are missing for some accounts, the pool config probably references a user that does not exist. Confirm: grep "^user = " /opt/cpanel/ea-php82/root/etc/php-fpm.d/<user>+<domain>.conf and id <user>.
  4. If sockets exist and FPM is up, check Apache’s expected socket path against the actual one: apachectl -t -D DUMP_INCLUDES | grep -A2 ProxyPass | head versus ls /opt/cpanel/ea-php82/root/usr/var/run/php-fpm/. Mismatches usually come from cPanel having generated the include before FPM finished starting.
  5. Force a regeneration: /scripts/rebuildhttpdconf && apachectl -t && apachectl graceful. Then systemctl restart ea-php82-php-fpm. Test.
  6. If the issue persists after both rebuilds, the EA4 provision likely failed partway through. See the EA4 rebuild recovery article.

For environments where post-provision 503s are part of the on-call playbook, Stack Harbor runs synthetic checks against every account after EA4 changes under WHM server management.