How to Change the Version of the 'php' Command
For each PHP version ServerPilot installs on your server, ServerPilot also installs the PHP command line interface (CLI) for that PHP version. Each PHP CLI version is available through a different command for each PHP version.
If you prefer to use just the command php without specifying a PHP version, your server's default PHP CLI version is used.
The default PHP CLI version will also be the PHP version used when you use Composer by calling the command composer without specifying a PHP version.
Similarly, the default PHP CLI version will also be the PHP version used when you use WP-CLI by calling the command wp without specifying a PHP version.
Determining the Current Version of the php Command
To see which PHP version is currently configured as the php command on your server, SSH in to your server and run the command:
You'll see output like this:
PHP 7.0.5 (cli) (built: Apr 4 2016 17:05:05) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
You can see the PHP version in the first line output. In the above example, the PHP version is 7.0.
If you see php: command not found, you should use the instructions below to set the version of the php command.
Set the Version of the php Command
To set or change the version of the php command, SSH into your server as root and run the following commands:
sudo apt-get install sp-php-cli
sudo dpkg-reconfigure sp-php-cli
You will be shown a menu allowing you to select the default PHP version for the php command. Once you select the version you want used as the default PHP CLI version, press Enter.
You can verify the default PHP CLI version was changed by running the command:
You'll see the new PHP version you've selected in the output.
Last updated: April 19, 2017