Skip to content

PHP CLI on cPanel running a different version than PHP-FPM

Why the PHP version reported by php -v from a cron job on a cPanel server can differ from the version PHP-FPM uses, and how to point a customer's cron at the right binary so cron-driven code matches the web tier.

A customer’s WordPress runs on PHP 8.2 via PHP-FPM but their cron-driven backup script throws PHP 7.4 deprecation warnings. The site itself is fine — it is the cron job that is wrong. The cause is that /usr/bin/php on a cPanel server is the server-default version, which can lag behind the account’s web version. Cron jobs use whatever shell PATH resolves to, not the account’s MultiPHP-Manager-assigned version.

What’s happening

cPanel maintains multiple PHP versions side by side: ea-php74, ea-php80, ea-php81, ea-php82, ea-php83. Each version has its own binary at /opt/cpanel/ea-php<ver>/root/usr/bin/php. The system-wide default /usr/bin/php is a symlink to one of these — whichever was the cPanel system default at the time it was set. MultiPHP Manager assigns a version per account for the web tier (PHP-FPM); it does not change the CLI symlink for that account. A cron job that runs /usr/bin/php script.php uses the system default, not the account’s web version.

How to verify

For a given account, find the gap:

whmapi1 php_get_vhost_versions vhost=example.com
ls -la /usr/bin/php
/usr/bin/php -v
ls /opt/cpanel/ea-php*/root/usr/bin/php
crontab -u <user> -l

Compare the web version (from whmapi1) to the CLI symlink target (from ls -la /usr/bin/php). If they differ, that account’s cron jobs are running on the wrong PHP.

The fix

  1. Per cron job, change the shebang or the explicit path to the account’s web version. Replace /usr/bin/php script.php with /opt/cpanel/ea-php82/root/usr/bin/php script.php (or whatever version the account’s web tier is on).
  2. For the account user’s interactive shell, set the path via cPanel > Software > Select PHP Version > take the line cPanel provides and add to .bashrc:
    alias php=/opt/cpanel/ea-php82/root/usr/bin/php
  3. For account-level cron consistency, edit the crontab via crontab -u <user> -e and replace every php call with the explicit versioned path. Document this so the customer knows what to use when they add new cron jobs.
  4. Server-wide cron jobs (root cron) should also use the explicit versioned path. /usr/bin/php is fine when the script genuinely does not care which version it runs, but it is a footgun when scripts have version-dependent dependencies.
  5. To change the system-wide default (rarely the right answer): WHM > MultiPHP Manager > System PHP Handler section > set System PHP version. This re-symlinks /usr/bin/php. Be aware that any system script or third-party tool that runs /usr/bin/php will now use the new version.
  6. Document the version each account expects for CLI work. The next operator who debugs “my cron stopped working” should be able to look up “uses ea-php82 explicitly.”

For environments where CLI-vs-FPM mismatches cause recurring tickets, Stack Harbor sets explicit-path conventions during onboarding under cPanel server management.