You can try this step :
Add PPA for PHP
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get updateInstall PHP8.0
sudo apt install php8.0Install PHP 8 Packages That You Need Example :
sudo apt install php8.0-common php8.0-mysql php8.0-xmlEnable PHP 8 and Restart Your Apache
sudo a2dismod php8.2
sudo a2enmod php8.0Check php version that now running
php -v
If it’s still show old php version then you can run bellow command and choose new php version from there list. so run bellow command:
sudo update-alternatives --config php
Repeat that step for another version that you want to running with your apache.
Hope this help. Thanks
Answer from okta rianzani on askubuntu.comYou can try this step :
Add PPA for PHP
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get updateInstall PHP8.0
sudo apt install php8.0Install PHP 8 Packages That You Need Example :
sudo apt install php8.0-common php8.0-mysql php8.0-xmlEnable PHP 8 and Restart Your Apache
sudo a2dismod php8.2
sudo a2enmod php8.0Check php version that now running
php -v
If it’s still show old php version then you can run bellow command and choose new php version from there list. so run bellow command:
sudo update-alternatives --config php
Repeat that step for another version that you want to running with your apache.
Hope this help. Thanks
Try to take a look here (is for Ubuntu 22.04 but I think it would be OK for 22.10 too):
https://techvblogs.com/blog/install-multiple-php-versions-on-ubuntu-22-04
You can install the versions of PHP that you want from the Ondrej PPA (you need ppa:ondrej/php, and it's advised also to get ppa:ondrej/apache2 or ppa:ondrej/nginx if you are using the appropriate web server.).
Use sudo update-alternatives --config php to switch between PHP versions.
Videos
Yes, you can. Please try to install like
$ sudo apt install php5.6
$ sudo apt install php7.0
Here php5.6 and php7.0 is PHP version
You can easily install both side by side, but I think your real question might be: "Can you run PHP 5 and PHP 7 simultaneously in a web-server on Ubuntu?".
Yes, that is possible! But no, it would take way too long to explain in a single answer here. It also depends on whether you use Nginx or Apache as your chosen webserver.
The short summary is:
- Install PHP-FPM 5.x as a service, and start it up.
- Install PHP-FPM 7.x as a service, and start it up.
- If you haven't installed your webserver yet, do that too.
- Configure your webserver so that when a PHP script is called, the call is passed to whichever PHP version you want.
Yes! This will require a bit of research on your part into PHP-FPM and webserver configuration. Googling for "ubuntu php-fpm simultaneously" should turn up plenty of links to get you started.