You can try this step :

  1. Add PPA for PHP

    sudo apt install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update

  2. Install PHP8.0

    sudo apt install php8.0

  3. Install PHP 8 Packages That You Need Example :

    sudo apt install php8.0-common php8.0-mysql php8.0-xml

  4. Enable PHP 8 and Restart Your Apache

    sudo a2dismod php8.2
    sudo a2enmod php8.0

  5. Check 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.com
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-ubuntu-20-04
How To Run Multiple PHP Versions on One Server Using Apache and PHP-FPM on Ubuntu 20.04 | DigitalOcean
June 30, 2020 - Now add the ondrej/php repository to your system. The ondrej/php PPA will have more up-to-date versions of PHP than the official Ubuntu repositories, and it will also allow you to install multiple versions of PHP in the same system:
🌐
Medium
medium.com › techvblogs › how-to-install-multiple-php-versions-on-ubuntu-22-04-3a0474b07385
How to Install Multiple PHP Versions on Ubuntu 22.04 | by Smit Pipaliya | TechvBlogs | Medium
July 20, 2022 - Then update the Apt cache and upgrade the current packages of the system using the following command: ... When prompted, press y to confirm the installation. The easiest way to install multiple versions of PHP is by using the PPA from Ondřej Surý, ...
🌐
Clouding.io
help.clouding.io › hc › en-us › articles › 360021630059-How-to-Install-Multiple-PHP-Versions-7-2-7-4-8-0-and-8-1-on-Ubuntu-20-04
How to Install Multiple PHP Versions (7.2, 7.4, 8.0 and 8.1) on Ubuntu 20.04 – Clouding.io
June 14, 2022 - This is very useful when you have multiple PHP applications on your server and each application is compatible with the different PHP versions. In this case, you can configure NGINX to define your desired PHP version. In this article, we'll show you how to install PHP 7.2, 7.4, 8.0 and 8.1 on Ubuntu ...
🌐
Database Mart
databasemart.com › kb › install-multiple-php-versions-on-ubuntu
How to Install Multiple PHP Versions Ubuntu
Learn how to install multiple PHP versions Ubuntu 18.04 (PHP 5.6, PHP 7.x, PHP 8.x) step by step. Beginner-friendly guide to setup PHP server Ubuntu with FPM and Apache.
🌐
TechvBlogs
techvblogs.com › blog › install-multiple-php-versions-on-ubuntu-22-04
How to Install Multiple PHP Versions on Ubuntu 22.04
April 18, 2025 - Then update the Apt cache and upgrade the current packages of the system using the following command: ... When prompted, press y to confirm the installation. The easiest way to install multiple versions of PHP is by using the PPA from Ondřej Surý, ...
Find elsewhere
🌐
DEV Community
dev.to › angelalexqc › installing-multiple-versions-of-php-on-ubuntu-debian-also-wsl-5hjp
Installing Multiple Versions of PHP on Ubuntu, Debian (also WSL). - DEV Community
May 4, 2024 - You can use any text editor to create the file. Let's name it install_php_versions.sh. ... Paste the script into the file and save it. Make the script executable using the following command: ... Now, you can execute the script to install multiple ...
🌐
GitHub
gist.github.com › raihan-uddin › ed5b6a024023096b88a41dd4a99f77a6
How to Run Multiple PHP Versions with Apache on Ubuntu 24.04/ 22.04 / 20.04 / 18.04 · GitHub
The command below includes some of the most popular PHP extensions, which should cover a typical WordPress site. Make sure to replace 7.4 with the version you require. sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl
🌐
LinuxBabe
linuxbabe.com › home › how to install multiple versions of php on ubuntu 22.04, 20.04, 18.04
How to Install Multiple Versions of PHP on Ubuntu 22.04, 20.04, 18.04
November 15, 2022 - Ubuntu 20.04 repository includes ... Ubuntu server. The easiest way to install multiple versions of PHP is by using the PPA from Ondřej Surý, who is a Debian developer....
🌐
Medium
medium.com › @sirajul.anik › running-multiple-php-versions-on-ubuntu-56638fcac968
Running multiple PHP versions on Ubuntu | by Syed Sirajul Islam Anik | Medium
August 14, 2021 - Source it with source ~/.bashrc or source ~/.zshrc and now you can switch between PHP versions using any of the following ... I have created the aliases because I don’t want to write load_php80 and also whenever I have PHP8.1 installed, the load_php8 will load the latest version of PHP8.x
🌐
Phoca
phoca.cz › home › blog
Running Multiple PHP Instances with LAMP Stack on Ubuntu/Kubuntu 23.10 Linux 2024 (Update 2026)
February 3, 2026 - And now we will install multiple instances of PHP. There will be two oddities: 1) to avoid conflicting PHP libraries, we will uninstall all the PHP libraries already installed. Be careful to do this step only if you are not using old PHP instances · sudo apt-get remove 'php*' sudo apt-get purge 'php*' 2) Add a new specific repository to our system that will allow us to install the latest PHP versions
🌐
TecAdmin
tecadmin.net › install-multiple-php-version-apache-ubuntu
Configuring the Multiple PHP Versions with Apache on Ubuntu
April 26, 2025 - To use the multiple PHP versions, we will use PHP FPM and FastCGI. Let’s install the following packages on your system. sudo apt update sudo apt install php8.1 php8.1-fpm sudo apt install php7.4 php7.4-fpm · After installation, php-fpm services ...
🌐
Liquid Web
liquidweb.com › home › update: install multiple php versions on ubuntu 16.04
Update: Install Multiple PHP Versions on Ubuntu 16.04 | Liquid Web
February 19, 2025 - Select php5.6 version to be set as default, in this case, its the number one option. You can now verify that PHP 5.6 is the default by running: php -v · Output: PHP 5.6.37-1+ubuntu16.04.1+deb.sury.org+1 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies ... Join our community today. ... Tutorials 1 min read How to Install or Uninstall PECL Extensions J.
🌐
TecAdmin
tecadmin.net › how-to-install-multiple-php-version-with-apache-on-ubuntu-20-04
How to Install Multiple PHP Version with Apache on Ubuntu 20.04 – TecAdmin
April 21, 2023 - Use the below couple of commands to add the PPA to your system. ... For this tutorial, we are using the PHP 5.6 and PHP 7.4 to configure with Apache web server. To use the multiple PHP versions, we will use PHP FPM and FastCGI.
🌐
Tutorials24x7
tutorials24x7.com › php › how-to-install-multiple-versions-of-php-on-ubuntu-2004-lts
Install Multiple Versions Of PHP On Ubuntu 20.04 LTS | Tutorials24x7
June 12, 2023 - This tutorial provides all the steps required to install multiple versions of PHP including PHP 7 and PHP 8 on Ubuntu 20.04 LTS using PPA. The steps should be similar to the other versions of Ubuntu and Linux-based systems. In case you are planning to use PHP with the Apache HTTP Server and MySQL database server, you can install Apache 2 and MySQL 8 before starting the installation of PHP 8.
🌐
DEV Community
dev.to › tanmaygi › how-to-install-multi-php-versions-on-ubuntu-2004amazon-ec2-server-1ehb
How to Install Multi-PHP versions on Ubuntu 20.04(Amazon EC2 server) - DEV Community
July 14, 2022 - Sometimes we need different applications (with different PHP versions running on it) but on a single server. So in this blog we’re going to do it step-by-step and configure NGINX to define our desired PHP version. We'll use AWS EC2 server and OS as Ubuntu 20.04.
🌐
Medium
psujit775.medium.com › how-to-install-multiple-php-versions-with-apache-on-ubuntu-b37cd23d3019
How to Install Multiple PHP Versions with Apache on Ubuntu | by Sujit Patel | Medium
December 24, 2022 - To run multiple versions of PHP simultaneously on Apache, you will need to use the Apache module fcgid. This module allows you to use FastCGI to execute scripts, including PHP scripts, and can be used to specify the version of PHP that should ...
🌐
TecMint
tecmint.com › home › linux distros › ubuntu › how to install different php (5.6, 7.x and 8.0) versions in ubuntu
How to Install Different PHP (5.6, 7.0 and 7.1) in Ubuntu
July 20, 2022 - In this article, we will explain how to install and set different versions of PHP - PHP 5.6, 7.0 and 7.1 in Ubuntu with most required PHP extensions.
🌐
Pleets
blog.pleets.org › article › en › install-different-versions-of-php-in-ubuntu-jammy-jellyfish
Install multiple versions of PHP on Ubuntu 22.04 (Jammy Jellyfish)
May 1, 2020 - You must type the option you want according to the versions you have installed. 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/php7.4 74 manual mode 2 /usr/bin/php8.1 81 manual mode Press