PHP is a popular server-side scripting language used for web development. With the release of PHP 8, many developers have upgraded their systems to take advantage of its new features. However, some developers have found that the latest version is not compatible with their existing applications or systems. In such cases, downgrading to an earlier version of PHP can be an effective solution.
In this article, we’ll provide a step-by-step guide to downgrading from PHP 8 to PHP 7 on Ubuntu.
Step 1: Enable PHP 7 repository
The first step is to enable PHP repository on your system. You’ll need to add the repository for PHP 7 to your system. To do this, you’ll need to run the following commands:
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Step 2: Install PHP 7
Once the repository for PHP 7 has been added to your system, you can install it using the following command:
sudo apt install php7.4
Also install other PHP modules as per the application requirements.
Step 3: Set PHP 7 as Default
Ubuntu allows us to install and use multiple php versions on a single system. You can simply set any version to use as the default version without uninstalling others.
sudo update-alternatives --config php
This will show you a list of install PHP version as below:
View 3 Comments
3 Comments
Danny on July 27, 2024 11:40 am Quick note, I had to change: sudo alternatives –config php sudo update-alternatives –config php Reply Brian on August 16, 2023 2:22 pm The PPA is not working do you have an update? I need to downgrade my php version.Regards Brian Reply Rahul on August 17, 2023 4:17 am Hi Brian,Which Ubuntu version are you running? Reply