Get your free beta license ↗
Websites · PHP

The php command uses a different version from the site

Last updated 30 Nov 2026
Summary

The php command at the shell uses a different PHP version from the site, so Composer, a cron job, or a script can behave differently. Use the full path to the binary for the site's version.

Symptoms

php -v prints a version different from the one the site runs. For example, the shell may report the version below.

php -v
Output
PHP 8.3.37 (cli) (built: Nov 17 2026 15:30:14) (NTS gcc aarch64)

Composer can refuse to run because of the project's PHP requirement, or a cron job can fail when it calls a function available on the site.

Cause

The shell and the site select PHP independently. On AlmaLinux, php runs the distribution's PHP. On Ubuntu, it runs the version selected by the alternatives system.

Each PHP version a site can run has its own binary. For PHP 8.4, it is /opt/remi/php84/root/usr/bin/php on AlmaLinux and /usr/bin/php8.4 on Ubuntu.

Resolution

  1. Find the site's PHP version in the php_running field of urbestack-domain-list. Use the full path to that version's binary. For PHP 8.4 on AlmaLinux, check the version with this command.

    /opt/remi/php84/root/usr/bin/php -v
  2. On Ubuntu, check it with this command.

    /usr/bin/php8.4 -v
  3. The output should show PHP 8.4.

  4. Use the same full path in cron jobs and when you run Composer. On Ubuntu, if Composer is installed at /usr/local/bin/composer, run /usr/bin/php8.4 /usr/local/bin/composer install.