Centos – How To Safely Downgrade PHP (7.1 to 7.0) on CentOS

centosPHPyum

I have a mission-critical production CentOS server running PHP7.1 from the remi repo. I need to downgrade PHP to 7.0. How can I do safely do this (What commands) with no downtime? Here's some output to provide some context.

# yum info php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.linux.duke.edu
 * epel: fedora-epel.mirrors.tds.net
 * extras: mirror.linux.duke.edu
 * remi-php71: remi.mirror.wearetriple.com
 * remi-safe: remi.mirror.wearetriple.com
 * updates: mirror.es.its.nyu.edu
Installed Packages
Name        : php
Arch        : x86_64
Version     : 7.1.12
Release     : 4.el7.remi
Size        : 9.4 M
Repo        : installed
From repo   : remi-php71
Summary     : PHP scripting language for creating dynamic web sites

How I originally upgraded to PHP7.1 was by enabling the remi php7.1 repo for PHP so now printing info for just php package shows the php7.1 package info as seen above. What I need is for yum info php to return the php 7.0 package that can be found in remi's php70 package:

# yum info php70
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.linux.duke.edu
 * epel: fedora-epel.mirrors.tds.net
 * extras: mirror.linux.duke.edu
 * remi-php71: remi.mirror.wearetriple.com
 * remi-safe: remi.mirror.wearetriple.com
 * updates: mirror.es.its.nyu.edu
Available Packages
Name        : php70
Arch        : x86_64
Version     : 1.0
Release     : 5.el7.remi
Size        : 2.9 k
Repo        : remi-safe
Summary     : Package that installs PHP 7.0
License     : GPLv2+
Description : This is the main package for php70 Software Collection,
            : that install PHP 7.0 language.

What commands would accomplish that and replace php7.1 with php7.0?

Best Answer

You should be able to achieve this with yum downgrade. The command in your case should be something like

yum downgrade php

which will give you the actions that yum will do and the option to proceed. You may have to do

yum --disablerepo remi-php71 downgrade php

if the first command doesn't show a downgrade path.

As always, test this before doing it on a production machine.