How can I change the PHP version used in console on Ubuntu 20.04? I have all versions in the /etc/php
folder, but I don't know where the configuration for the command line version is.
How can I change the PHP version used in console on Ubuntu 20.04? I have all versions in the /etc/php
folder, but I don't know where the configuration for the command line version is.
You can do this with
update-alternatives
. If you would like to do this interactively, you can do this:If you like to specifically choose the PHP version (via an alias or whatnot), you can do this:
Of course, be sure to change
php7.4
to the actual version you want to switch between.Please use following command which will ask you to select a number against your required PHP version
Then select your choice and press enter.
i just try in Ubuntu20.04 and it works.
// to show the list php installed: sudo update-alternatives --config php
// choose number version that you wanna switch screenshoot switch php version in ubtuntu
Put the above alias in
~/.bashrc
:Then just run this command:
Now you can run the command
setphp
from your terminal.