In my case, I solved it this way.
When giving a which php
, the same points to the way /usr/bin/php
. I found that this is actually just a link to the latest php installation.
So I deleted the link
and created another one pointing to version 5.6 of PHP.
Thus:
sudo rm /usr/bin/php
sudo ln -s /usr/bin/php5.6 /usr/bin/php
If you execute the command php -v
, will notice that the result will look something like this:
php -v
> PHP 5.6.30-7+deb.sury.org~xenial+1 (cli)
Thus, when rotating the composer install
, executed PHP will be the version placed in the symbolic link of /usr/bin/php
.
Updating
The way used above was a manual way that I used to solve the problem, but the most recommended way is to use the Linux command itself, called update-alternatives
. With it we can determine symbolic links to certain commands.
Just do it like this:
sudo update-alternatives --set php /usr/bin/php5.6
If you want to use the version 7.1
, for example, just do:
sudo update-alternatives --set php /usr/bin/php7.1
Remember that PHP versions must be installed in your :p OS
very good, I maintain 2 versions of PHP and HHVM in this way that you cited +1
– Guilherme Nascimento