Skip to content

PHP handlers on cPanel — security tradeoffs between DSO, CGI, suPHP, FPM

Pick the safest PHP handler on a cPanel server that hosts more than one account. PHP-FPM runs each account's PHP under its own user and stays fast, while DSO and CGI run everything as Apache and let one compromised site read the others.

On a cPanel server that hosts more than one account, use PHP-FPM as your PHP handler, the component that decides how PHP code runs and under which user. cPanel’s MultiPHP Manager offers four handlers, and only two of them, PHP-FPM and suPHP, run each account’s PHP under that account’s own Linux user. DSO and CGI run every site’s PHP as the Apache user, so one compromised site can read the files of every other account on the server. suPHP isolates accounts too but is very slow, which leaves PHP-FPM as the one handler that is both isolated and fast. On a server with a single customer, any handler is acceptable.

What’s happening

The PHP handler determines which UID executes the PHP code. DSO loads PHP as a module inside the Apache process — runs as Apache UID, fast, no isolation. CGI starts a new PHP process per request — runs as Apache UID by default, slow, no isolation. suPHP starts a new PHP process per request, running under the account’s UID via setuid — isolated, very slow. PHP-FPM uses a long-running pool per account UID — isolated, fast. The performance and security tradeoffs are independent dimensions.

How to verify

whmapi1 php_get_handlers
whmapi1 php_get_users_with_handler handler=dso
whmapi1 php_get_users_with_handler handler=fpm
ps auxf | grep php | head -20
cat /etc/cpanel/ea4/php.conf

If php_get_users_with_handler handler=dso returns any account on a multi-tenant host, you have an exposure.

The fix

The decision rule:

  1. Multi-tenant host, want isolation and performance: PHP-FPM. Choose this. Every account gets its own pool running as the account UID, fast enough for production, isolated.
  2. Multi-tenant host, low traffic, can tolerate slow: suPHP. Older option, still isolated by UID, slower than FPM, but simpler. Use only if FPM is not available for some reason.
  3. Single-tenant host (one customer, dedicated server): any handler works. DSO is fastest. The isolation question is moot.
  4. DSO on a multi-tenant host: avoid. The shared UID is a foothold escalation waiting to happen.
  5. CGI without FPM: also avoid. It runs as Apache UID by default and has no isolation benefit over DSO.
  6. Per-version handler choice: cPanel lets you set the handler per PHP version. PHP-FPM for current versions, suPHP only if legacy PHP needs an unsupported handler.
  7. Migration cadence: when moving an existing host from DSO to FPM, do it during a maintenance window. The first restart can take 30–60 seconds while pools initialize.

Stack Harbor standardizes on PHP-FPM on managed multi-tenant hosts as part of WHM server management.