Shared Hosting - PHP CLI Version

Is there any way to specify which PHP version to use when in the command line? I currently see that the version is 5.6.36 when I invoke it on Cherokee.

You can access different versions using version-specific names:

php-5.6     php-7.0     php-7.1     php-7.2

To the point.


If you want to change the unversioned default php, you can add one of the versioned PHP bin directories to your path:

export PATH=/usr/local/php71/bin:$PATH 

The DH help article has full details:

please note: even if you change your .bash_profile to specify a PHP CLI version, this appears to have no affect on your crons. in other words if you add…

export PATH=/usr/local/php72/bin:$PATH

…to your .bash_profile and in your crons you do something like:

php /path/to/script.php

your cron will still use PHP 5.6. you still have to specify the complete path to your desired PHP version in your cron, likle this:

/usr/local/php72/bin/php /path/to/script.php

this appears to be the case even if you update your .bashrc to look like this:

source .bash_profile

still not sure why this is. seems that .bash_profile + .bashrc would effect the default PHP CLI used by cron, which is running as your DH user, which should inherit your bash settings. would welcome some input from the DH admins about this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.