1. Home
  2. Technical
  3. How to change default php-cli in console

How to change default php-cli in console

Our platform uses at least 6 month old PHP stable version for it’s default in SSH php-cli.

You can check the current version used like this:

php -v

This gives the following answer:

virt490:sn-69-31.tll07.zoneas.eu:~> php -v
PHP 7.2.4 (cli) (built: May 3 2018 22:32:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies

For changing default version you need to create symlink to desired PHP version ~/bin/ folder.

This is for example to use PHP 7.1:

mkdir -p ~/bin && ln -sf /opt/zone/bin/php71-cli ~/bin/php

After running this command, re-login to SSH, after that php -v shows version 7.1.

If you need to run PHP 5.6 or 7.0 then you must create symlink to php56-cli or php70-cli.

NB! After creating this link, PHP CLI version will not change automatically in the future.
To remove the excising symlink run this command:

rm -f ~/bin/php

Updated on 18. Oct 2018

Was this article helpful?

Related Articles