xxxxxxxxxx
sudo apt-add-repository ppa:ondrej/php
sudo apt update
//then
sudo apt install -y php8.0 php8.0-cli php8.0-common
xxxxxxxxxx
PHP UPGRADE (7.2 TO 8.2)
sudo add-apt-repository ppa:ondrej/php && sudo apt update
//or sudo apt-add-repository ppa:ondrej-ubuntu-php && sudo apt update
sudo apt update
sudo apt install php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-gd php8.2-intl php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-xml php8.2-zip
a2dismod php7.2 #Disable php7.2
a2enmod php8.2 #Enable php8.2
sudo service apache2 restart
sudo update-alternatives --config php #switch php terminal
sudo service apache2 restart
xxxxxxxxxx
There are two methods to switch php versions on the command line ubuntu.
Run each command one by one and input the number of the php version you want to change.
**Method 1**
sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar
sudo service apache2 restart
**Method 2**
If you want to change PHP 5.6 to 7.4 just run the below codes.
sudo a2dismod php5.6
sudo a2enmod php7.4
sudo service apache2 restart
If you want to change from PHP 7.4 to 5.6 run the below codes.
sudo a2dismod php7.4
sudo a2enmod php5.6
sudo service apache2 restart
For more information follow this link https://slaford.com/laravel/how-to-switch-php-versions-on-command-line-ubuntu/
xxxxxxxxxx
There are two methods to switch php versions on the command line ubuntu.
Run each command one by one and input the number of the php version you want to change.
**Method 1**
sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar
sudo service apache2 restart
**Method 2**
If you want to change PHP 5.6 to 7.4 just run the below codes.
sudo a2dismod php5.6
sudo a2enmod php7.4
sudo service apache2 restart
If you want to change from PHP 7.4 to 5.6 run the below codes.
sudo a2dismod php7.4
sudo a2enmod php5.6
sudo service apache2 restart
For more information follow this link https://slaford.com/laravel/how-to-switch-php-versions-on-command-line-ubuntu/