Handle multiple PHP versions.
Install PHP version
sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https
Add required PPA
LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php
Update registry
sudo apt update
Install php version
sudo apt install php8.0
sudo apt install php8.0-mysql php8.0-mbstring php8.0-xml php8.0-curl php8.0-gd
switch php versions and enable new version
sudo update-alternatives --config php
There are 2 choices for the alternative php (providing /usr/bin/php).Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php8.1 81 auto mode
* 1 /usr/bin/php8.0 80 manual mode
2 /usr/bin/php8.1 81 manual modePress <enter> to keep the current choice[*], or type selection number:
Enable a PHP version
sudo a2enmod php8.0
sudo systemctl restart apache2
Disable a PHP version
sudo a2dismod php8.1
sudo systemctl restart apache2