Skip to content

PHP-FPM and suEXEC on cPanel — what they actually isolate

How PHP-FPM pools and suEXEC keep cPanel tenants from reading each other's files, and the gaps each leaves that need to be closed explicitly.

Multi-tenant cPanel hosts live or die on inter-account isolation. The default Apache mod_php runs as the Apache user across all accounts — meaning a webshell in one account can read every other account’s files. PHP-FPM with suEXEC fixes that, but only if it’s configured per-account and not bypassed. CageFS on CloudLinux is the stronger version of the same idea.

What’s happening

cPanel supports two PHP handlers worth using on a multi-tenant host: suPHP (CGI-based, runs PHP as the account user, slow) and PHP-FPM (FastCGI, dedicated pool per account, fast). Both isolate PHP execution to the account’s UID, so a compromised account cannot read /home/<other-user>/ directly. mod_php and the older DSO handler do not isolate — they are inappropriate for shared hosting.

How to verify

whmapi1 php_get_handlers
whmapi1 php_get_users_with_handler handler=fpm
ls -la /opt/cpanel/ea-php74/root/usr/share/cagefs-skeleton 2>/dev/null
ps auxf | grep -E "php-fpm|httpd" | head -20
cat /var/cpanel/userdata/<user>/<domain>.php-fpm.yaml 2>/dev/null

ps auxf shows whether php-fpm pools are running as the cPanel users or as a single shared user.

The fix

  1. WHM > MultiPHP Manager: set every account’s PHP handler to PHP-FPM. The default in cPanel-recent installs is suphp, which works but is slow. PHP-FPM is the recommended path.
  2. Per-account FPM pool: whmapi1 php_set_user_handler user=<user> handler=fpm. Each account gets its own pool running as the account UID.
  3. Confirm open_basedir for each pool. cPanel sets open_basedir = /home/<user>/:/tmp/ by default; verify in /var/cpanel/userdata/<user>/<domain>.php-fpm.yaml. This prevents PHP from reading other accounts even if the UID checks were bypassed.
  4. CageFS on CloudLinux: provides chroot-like isolation per account, hiding /etc/passwd, /proc, and other accounts’ home directories. If CloudLinux is licensed, enable CageFS for every account in WHM > CloudLinux > CageFS Management.
  5. disable_functions: in each FPM pool, disable exec, system, passthru, shell_exec, proc_open, popen, pcntl_exec. These are the functions a webshell needs. The downside: some legitimate WordPress plugins use proc_open — exception per-account if needed.
  6. upload_tmp_dir and session.save_path inside each account’s home, not shared /tmp. cPanel sets this automatically with FPM pools.
  7. Audit periodically: a for u in $(whmapi1 listaccts); do whmapi1 php_get_user_handler user=$u; done makes sure no account has been silently switched to dso or mod_php.

Stack Harbor enforces PHP-FPM with per-account isolation under cPanel server administration.