For some reason, i have to install PHP 7.4 and PHP 8.0 in the same ubuntu server. By default when i install php 7.4, it shows it is the default version when use the command php -v.
But i want to run composer using PHP 8.0 now to install one of my application in the server. Server cant find any php version now, so i cant install my application using composer.
How did i install PHP 8.0
I have used sudo add-apt-repository ppa:ondrej/php this repository to install latest version of 8.0 in the server, I can make it work with caddy server and even site is running fine in my testing environment. << you can check out this URL to make sure my 8.0 is running fine in server.
Anyway i have removed PHP 7.4 from server to make sure does it help me to set 8.0 as default one, but no i can't get it to work.
php --versionScreen Shot Image of php version result from the server
Help me out to set PHP 8.0 as default version in server now. Thanks.
1 Answer
You will likely need to do two things:
- Set the alternative version to your 8.0 installation:
sudo update-alternatives --set php /usr/bin/php8.0 - Confirm you have the CLI (Command Line Interface) package installed:
sudo apt install php8.0-cli
From here you should be good to go.