How to change PHP CLI version for composer and plesk at the command line

How to change PHP CLI version for composer and plesk

Below is the command line code for changing the default PHP version in Plesk. If you are using Plesk as I do on a number of VPS servers, even though you can change the php version inside the Plesk domain control panel, this does not change it at the command line.

I use Putty to connect to the command line. To connect your domain name in Plesk to the command line, you go to "Web hosting access" in the domain subscription type.

Here you will find the two important things.

1) A field with your "username" already filled in.

2) The IP address for the domain name

You use both the username and the ip address to connect to the command line for this domain with the following pattern:

username@ipaddress

This will then take you to the login screen where you then enter your password. Your password is also set in the "Web hosting access" System user section. You can then use the following to choose with php version you want to use. Obviously change 7.2 to the version of your choice!

/opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar