Downgrade Php 8 To 7.4 Centos 7

admin14 April 2024Last Update :

Understanding the Need for Downgrading PHP

Downgrading PHP from version 8 to 7.4 on CentOS 7 can be necessitated by various factors such as compatibility issues with applications or specific libraries that are not yet fully compatible with PHP 8. It’s crucial to ensure that your system’s stability and application performance are not compromised due to version incompatibility.

Prerequisites Before Downgrading PHP

Before proceeding with the downgrade process, it is essential to have a complete backup of your system and data. Ensure you have root access to your CentOS 7 server and that all current work on the server is saved, as the process may require restarting services or the entire server.

Backup Your Data

Step 1: Backup existing PHP configurations and websites.
Step 2: Export databases that interact with PHP-based applications.

Check Current PHP Version

Use the command

php -v

to check the current PHP version installed on your CentOS 7 server.

Removing PHP 8 from CentOS 7

The first step in downgrading is to remove the existing PHP 8 installation. This can be done using the YUM package manager.

Uninstall PHP 8 Packages

Run the following command to remove PHP 8 packages:

yum remove php*

Installing PHP 7.4 on CentOS 7

Once PHP 8 has been removed, the next step is to install PHP 7.4. CentOS 7 does not provide PHP 7.4 in its default repositories, so we will need to enable a third-party repository like Remi’s RPM repository to install PHP 7.4.

Enable Remi Repository

Install the EPEL repository and then the Remi repository using the following commands:

yum install epel-release
yum install

Install PHP 7.4

With the Remi repository enabled, you can now install PHP 7.4:

yum-config-manager --enable remi-php74
yum install php php-cli php-fpm php-common

Configuring PHP 7.4

After installing PHP 7.4, it’s important to configure it according to your application requirements. This includes editing the php.ini file and other related configuration files.

Edit php.ini File

Locate and edit the php.ini file to tweak settings such as memory limit, upload size, and execution time:

nano /etc/php.ini

Configure PHP-FPM (If Used)

If you’re using PHP-FPM, make sure to adjust its settings accordingly:

nano /etc/php-fpm.d/www.conf

Testing PHP 7.4 Installation

To verify that PHP 7.4 is installed correctly, create a test PHP file with the following content and view it in a web browser:

echo "" > /var/www/html/phpinfo.php

Troubleshooting Common Issues After Downgrade

It’s not uncommon to encounter issues after downgrading PHP. Here are some steps to troubleshoot common problems.

Extensions and Modules Compatibility

Ensure that all required PHP extensions and modules are installed and compatible with PHP 7.4. Use the command

yum search php-

to find available PHP modules and extensions.

Code Compatibility

Review and update any code that may be incompatible with PHP 7.4, paying attention to deprecated features and functions that were valid in PHP 8 but not in PHP 7.4.

Maintaining Security Post-Downgrade

Security is paramount, especially when running an older version of PHP. Regularly apply security patches and updates to PHP 7.4 to mitigate vulnerabilities.

Applying Security Updates

Keep PHP 7.4 secure by applying updates:

yum update php*

FAQ Section

  • Why would I need to downgrade from PHP 8 to PHP 7.4?

    You might need to downgrade if your applications or scripts are not fully compatible with PHP 8.

  • Is it safe to downgrade PHP versions?

    While it is technically possible to downgrade, it should be done cautiously, ensuring backups are made and thorough testing is conducted post-downgrade.

  • Can I use yum to downgrade PHP directly?

    Yum does not support straightforward downgrades. You must remove the current version and then install the desired version.

  • How do I know which PHP extensions to reinstall after downgrading?

    You should review your application requirements and previous configurations to determine which extensions are necessary.

  • Will my website experience downtime during the downgrade process?

    There may be brief downtime while services are restarted or configurations are reloaded. Plan the downgrade during off-peak hours to minimize impact.


Leave a Comment

Your email address will not be published. Required fields are marked *

Comments Rules :

Breaking News