As a web developer, I understand the significance of embracing the latest technologies to stay ahead in the dynamic world of web development. PHP 8 undoubtedly caught my attention with its impressive performance improvements and cutting-edge features. Excited to explore its potential, I upgraded my Ubuntu machine to PHP 8 to take advantage of its benefits.
However, in this journey, I encountered a few compatibility issues with existing codebases and certain software dependencies.
It became clear that a rollback to a more stable environment, like PHP 7.4, was necessary to ensure a seamless development experience.
If you, too, find yourself facing similar challenges and wish to revert from PHP 8 to PHP 7.4 on your Ubuntu system, fear not! In this article, I will share my step-by-step guide on how I accomplished this version downgrade.
Whether you're a seasoned developer or just starting your coding journey, I hope my instructions will help you navigate this process with ease.
While PHP 8 offers exceptional enhancements, I found PHP 7.4 to be a popular and reliable choice among developers, backed by its mature ecosystem and extensive support for various projects.
Through this article, I aim to provide a comprehensive approach to downgrading PHP versions while minimizing any potential disruptions.
So, if you're ready to explore the process of reverting to PHP 7.4, join me as we dive into the world of version management on your Ubuntu server or local machine.
By the end of this article, I hope you'll gain the confidence to make informed decisions regarding your PHP setup and ensure your web applications continue to run smoothly.
Let's get started how to downgrade php 8 to 7.4 in Ubuntu, how to downgrade PHP version in Ubuntu, how to downgrade PHP version in XAMPP, switch php 8 to 7.4 Ubuntu, and how to change php version in Ubuntu.
Before starting the downgrade, check the current PHP version on your Ubuntu system using the following command.
This will display the installed PHP version.
Next, you’ll need to add the repository for PHP 7 to your system. if you have already installed PHP 7 in your system then ignore this step. So, run the following command.
sudo apt update sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update
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
Ubuntu allows us to install and use multiple PHP versions on a single system. You can easily set any version as the default without uninstalling others.
sudo alternatives --config php
This will show you a list of installed PHP versions as below.
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 <enter> to keep the current choice[*], or type selection number:
Enter the selection number to make any PHP version as default. For example, to set PHP 7.4 as default, input “1” and hit enter.
To verify that PHP 7 has been installed, run the following command.
This should display the version of PHP that is currently installed on your system.
PHP 7.4.33 (cli) (built: Nov 8 2022 11:33:35) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
Then, need to configure PHP 7 to work with your system and applications. You can do this by editing the php.ini file using the following command.
sudo nano /etc/php/7.4/cli/php.ini
You can make any necessary changes to the file and then save it.
In conclusion, Ubuntu's flexibility in accommodating multiple PHP versions on a single system provides web developers with a powerful tool to manage their PHP environments efficiently. The ability to switch between different PHP versions without the need for uninstallation enables seamless testing and development across various projects.
The step-by-step guide presented in this article has demonstrated the straightforward process of downgrading PHP from version 8 to version 7.4 on an Ubuntu machine.
You might also like: