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

Top DataOps Pipeline Testing Tools for Modern Data Teams

Introduction Modern data pipelines are complex distributed systems. A standard production workflow connects transactional databases, third-party APIs, object storage, streaming queues, transformation layers, cloud data warehouses, and…

Read More

Accelerating Pipeline Root Cause Analysis Using Telemetry and Graph Intelligence

Modern enterprise data architectures rely on an intricate web of batch jobs, streaming brokers, cloud warehouses, and SaaS APIs where standard task monitoring often falls short—a pipeline…

Read More

AI Agents and the Future of Intelligent Business Automation

Introduction From an engineering leadership perspective, the primary friction in enterprise software today is not model intelligence—it is operational determinism. Software teams can rapidly configure a conversational…

Read More

Building Reliable Software Delivery with DevOps Consulting Services

Introduction Modern engineering organizations face mounting pressure to accelerate deployment frequency without compromising production stability or data security. However, transitioning from fragmented release processes to automated, cloud-native…

Read More

AI Software Development Guide for Startups and Enterprise Teams

Introduction Engineering executives, CTOs, and technical directors face a common operational dilemma: engineering headcount grows, but feature velocity steadily drops. As application architectures expand into distributed services,…

Read More

Website Development Services: What Businesses Should Evaluate Before Hiring

Introduction Most website failures do not start in the design mockups; they originate deep within the backend infrastructure. When leadership teams treat web builds as purely visual…

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