How To Downgrade PHP 8 to 7.4 in Ubuntu?

Introduction

Have you recently updated your PHP version and encountered compatibility issues with your existing code? Don’t worry, you’re not alone. Many developers face this challenge when upgrading to the latest PHP version. In this blog post, we’ll guide you on how to downgrade PHP 8 to 7.4 in Ubuntu with a live example.

Why Downgrade PHP?

Before we dive into the process, let’s quickly discuss why you might need to downgrade PHP. While the latest PHP version brings improvements and new features, it can also introduce compatibility issues with older codebases. Some frameworks, libraries, or plugins may not be fully compatible with PHP 8 yet. Downgrading to a stable and widely supported version like PHP 7.4 can help ensure the smooth functioning of your applications.

Step-by-Step Guide to Downgrade PHP 8 to 7.4

Step 1: Check Current PHP Version

The first step is to check the current PHP version installed on your Ubuntu system. Open the terminal and enter the following command:

php -v

This command will display the current PHP version installed.

Step 2: Remove PHP 8

To downgrade PHP, we need to remove the PHP 8 packages from our system. Run the following command in the terminal:

sudo apt-get purge php8.*

This command will remove all PHP 8 packages from your Ubuntu system.

Step 3: Add PHP 7.4 Repository

Next, we need to add the PHP 7.4 repository to our system. Run the following commands in the terminal:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

These commands will add the PHP 7.4 repository and update the package list on your Ubuntu system.

Step 4: Install PHP 7.4

Now, it’s time to install PHP 7.4 on your Ubuntu system. Run the following command in the terminal:

sudo apt-get install php7.4

This command will install PHP 7.4 and its dependencies on your system.

Step 5: Install PHP 7.4 as Default

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.

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.

Step 6: Verify PHP Version

To ensure that the downgrade was successful, verify the PHP version once again using the following command:

php -v

Step 7: Configure PHP 7

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.

Congratulations! You have successfully downgraded PHP 8 to 7.4 on your Ubuntu system.

Related Posts

Navigating Brain Surgery Hospitals, Clinical Teams, and Treatment Paths

When a neurological disorder or intracranial diagnosis enters a family’s life, the immediate emotional response is often accompanied by an overwhelming amount of clinical data. Patients and…

Read More

Secrets of Lost Recipes: Ancient Tastes and Traditions

Every family kitchen holds sensory memories: the rhythmic tapping of a wooden spoon, the sharp crackle of seeds hitting hot oil, or the sweet fragrance of seasonal…

Read More

Top Predictive Maintenance Tools and Strategies for Data Platform Engineering

Introduction Every data engineer knows the frustration of waking up to broken data pipelines, corrupted tables, or an executive dashboard showing blank tiles. Traditionally, data teams discover…

Read More

The Complete Guide to Automating Analytics Pipelines and Workflows

Introduction Picture this scenario: An analyst arrives at work, opens a key executive dashboard, and discovers the numbers are completely outdated because a scheduled data extract failed…

Read More

A Fresh Way to Explore Bhopal Events, Attractions, and Local Experiences

Uncovering the authentic spirit of the City of Lakes goes well beyond visiting historical monuments and snapping photos of scenic waters. The true essence of Bhopal thrives…

Read More

Understanding Common Spinal Conditions and Researching Specialized Care Facilities

Introduction Finding the right hospital for a spine problem is not always as simple as searching for the best spine hospitals and choosing the first result. Patients…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x