Development and databases

PHP binary paths for each version

Reviewed on 3 min read php binarios

The php command in the terminal and in cron jobs usually uses the general version selected in cPanel's PHP selector, with the modules enabled for it, but do not take it for granted: we have seen accounts where it answered with PHP 8.1 while the selector was on 8.4, and /usr/local/bin/php does not necessarily match your website either. Always check with php -v and, to run a command with a specific version, call its binary by its absolute path. A version set for a folder in .htaccess affects web requests for that folder, not the terminal or your cron jobs.

Use the absolute path when a task must run with a specific version: in an application's cron, such as Laravel's schedule:run, it is the safest choice. These are the ALT-PHP paths; check that the binary is installed on your account before using it:

Version Path
5.4 /opt/alt/php54/usr/bin/php
5.5 /opt/alt/php55/usr/bin/php
5.6 /opt/alt/php56/usr/bin/php
7.0 /opt/alt/php70/usr/bin/php
7.1 /opt/alt/php71/usr/bin/php
7.2 /opt/alt/php72/usr/bin/php
7.3 /opt/alt/php73/usr/bin/php
7.4 /opt/alt/php74/usr/bin/php
8.0 /opt/alt/php80/usr/bin/php
8.1 /opt/alt/php81/usr/bin/php
8.2 /opt/alt/php82/usr/bin/php
8.3 /opt/alt/php83/usr/bin/php
8.4 /opt/alt/php84/usr/bin/php
8.5 /opt/alt/php85/usr/bin/php

Each binary loads the extensions selected for that specific version. If a cron job uses PHP 8.3 and the website uses another version, also enable on PHP 8.3 the modules the command requires.

Check version, configuration and modules

For example, for PHP 8.3:

/opt/alt/php83/usr/bin/php -v
/opt/alt/php83/usr/bin/php --ini
/opt/alt/php83/usr/bin/php -m

If you see "No such file or directory", check the available versions; typing the path does not install that version. To check what the short command resolves to, use command -v php and php -v.

Use the binary in a task

This example runs a script with PHP 8.3 from its working directory:

cd /home/usuario/apps/mi-proyecto && /opt/alt/php83/usr/bin/php scripts/tarea.php

Replace both paths and first test the command with a task you can run without duplicating operations. In cPanel, enter the command in Cron Jobs and set the frequency in the scheduling fields. At first, keep a private diagnostic output to check that it finishes correctly.

Choosing a different binary does not change the web version or guarantee that its extensions and options match. Check every context the application uses.

You may also find useful

Something wrong or out of date? Tell us and we will review it.