How to downgrade PHP-FPM on the CentOS server
During the installation and use process, you installed the PHP-FPM version too high, which is unsuitable for the services and applications on the server for some reasons such as services, applications just running In low PHP, service applications not being updated to be compatible with the new PHP. So when you encounter this situation and you are forced to downgrade the PHP version for compatibility.
Back to the article, I just installed PHP 8.0.1, this is the latest PHP version that was just released on 11/26/2020 and you can see the changes of PHP at this link. Because the PHP version is too high, the Themes and Plugins on my WordPress website cannot work and cause errors. Therefore, I have to downgrade PHP-FPM. And on how to downgrade, please follow along.
- See more: How to install LEMP Stack on Centos 7
II. Implementation Guide
To downgrade PHP-FPM, you follow 4 these steps.
Step 1: Check the current PHP version
To check the current PHP-FPM version, use the
php-fpm -v command:
And my version is PHP 8.0.1, I will downgrade it to PHP 7.3
Step 2: Backup the configuration file
Because when you downgrade, the system will rewrite the configuration file to the original default. Therefore, you need to back up the old configuration file to restore it when the downgrade is complete.
I will clone into a new copy with the accompanying name
.bak as follows: I will backup the configuration file
cp /etc/php.ini /etc/php.ini.bak cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.bak
Step 3: Uninstall the PHP package
Next, you need to remove the PHP packages that appear to install on the new PHP package. And to check php packages, you can use the
rpm -qa command:
- See also: Instructions for using RPM on Linux
rpm -qa | grep php
And then remove all installed PHP 8.0 packages and dependencies with the following command with the
yum remove command.
yum remove php-*
Step 4: Install the new PHP package
Now perform the PHP-FPM downgrade with the following command: Disable the old repo and enable the new repo. Since I need to downgrade PHP8 to PHP73, I will do
Note: Please change the current PHP version and the version you need to downgrade for the system to work correctly.
yum --disablerepo=remi-php80 --enablerepo=remi-php73 install php php-common php-gd php-xml php-fpm php-mysqlnd php-json php-mbstring php-xmlrpc php-opcache php-mysql
Downgrading time is quite fast. It only takes a few minutes to complete and after the downgrade is successful, you can restore the previously backed-up configuration files.
rm -rf /etc/php.ini mv /etc/php.ini.bak /etc/php.ini rm -rf /etc/php-fpm.d/www.conf mv /etc/php-fpm.d/www.conf.bak /etc/php-fpm.d/www.conf
Start and check the PHP-FPM status
systemctl start php-fpm systemctl enable php-fpm systemctl restart php-fpm systemctl status php-fpm
And now use the
php -v command again to check the PHP version. As shown below, I have done the complete downgrade.
- How to install Redis 6 on CentOS 7
- Setting up Nginx FastCGI Cache on NGINX reduces server response time
So with the above steps, you have downgraded PHP-FPM completely and effectively. Wishing you success! See more useful articles about Linux VPS at the following link:
If you need assistance, you can contact support in the ways below: