Out of the box, our default CLI PHP setting is 7.3, soon to be updated to 7.4 out of the box. However, on some older servers, this may still be set to the default of PHP 7.2.
Some programs (such as Composer for example) require a higher version of CLI than the default 7.2 version which may require you to update this to a higher version.
Here’s an example of this error from a site where SSO was failing to generate a login link:
Your Composer dependencies require a PHP version “>= 7.3.0”. You are running 7.2.25-1+ubuntu18.04.1+deb.sury.org+1. Error Code: 100 | PHP Errors stopping SSO Link creation, please check logs….
Here Composer is using the CLI PHP version, and not the FPM one that is used by sites. Switching the PHP version of your sites will not fix this specific issue as this only changes the PHP version for FPM.
This is a quick and easy fix though.
Updating the CLI PHP Version
To run this update you will need to SSH into your server. Please see the following guides to get started:
Generate your SSH Key:
Add your SSH Key to GridPane:
Connect to your server:
Checking your CLI PHP Version
To check your CLI PHP version, you can run the following command:
sudo update-alternatives --display php
This will output the following, only with the correct PHP version should your setting be different:
root@servername:~# sudo update-alternatives --display php
php - auto mode
link best version is /usr/bin/php7.3
link currently points to /usr/bin/php7.3
link php is /usr/bin/php
slave php.1.gz is /usr/share/man/man1/php.1.gz
/usr/bin/php7.3 - priority 73
slave php.1.gz: /usr/share/man/man1/php7.3.1.gz
Changing your CLI PHP Version
Next, you need to run the following command to change the CLI version:
sudo update-alternatives --set php /usr/bin/php7.X
X = the version number, which could be 1,2,3,4.
sudo update-alternatives --set php /usr/bin/php7.3
Once done, you’re all set!