How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
- 00:43 php -v
- 00:53 rpm -qa | grep php
- 01:07 yum remove "php-*" -y
- 01:19 yum --disablerepo=remi-php72 --enablerepo=remi-php73 install php php-gd php-mbstring php-mysql php-curl php-mcrypt
- 02:02 rpm -qa | grep php
- 02:17 yum remove "php-*" -y
- 02:28 yum --disablerepo=remi-php73 --enablerepo=remi-php56 install php php-gd php-mbstring php-mysql php-curl php-mcrypt
- 02:46 php -v
How to Upgrade and Downgrade the php version On CentOS 7.6
PHP is a server-side scripting language which is used to develop static websites or Dynamic websites or Web applications. PHP stands for Hypertext Pre-Processor that earlier stood for personal Home Pages. PHP scripts can only be interpreted on a server that has PHP installed. This tutorial covers the tutorial about Upgrade and Downgrade the php versions of CentOS 7.6
Procedure:
check the version of PHP
Query and List all the Installed rpm packages of php
Remove the PHP Packages
Disable and Enable the required php Versions and installing the php modules as well
CHeck the version of PHP
Check the modules of PHP In The current enabled php version
Pre-requisites:
remi and yum-utils third party repositories with php installed
Before you begin, check the version of PHP you are using.
[root@linuxhelp ~]# php -v
PHP 7.2.17 (cli) (built: Apr 3 2019 10:02:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Query and list all the installed rpm packages of php7.2v.
[root@linuxhelp ~]# rpm -qa | grep php
php-mysqlnd-7.2.17-1.el7.remi.x86_64
php-pecl-zip-1.15.4-1.el7.remi.7.2.x86_64
php-json-7.2.17-1.el7.remi.x86_64
php-mbstring-7.2.17-1.el7.remi.x86_64
php-7.2.17-1.el7.remi.x86_64
php-xml-7.2.17-1.el7.remi.x86_64
php-cli-7.2.17-1.el7.remi.x86_64
php-gd-7.2.17-1.el7.remi.x86_64
php-pdo-7.2.17-1.el7.remi.x86_64
php-common-7.2.17-1.el7.remi.x86_64
php-pecl-mcrypt-1.0.2-2.el7.remi.7.2.x86_64
Upgrade from 7.2v to 7.3v:
Remove the installed php packages of 7.2v to upgrade to 7.3v.
[root@linuxhelp ~]# yum remove "php-*" -y
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-cli.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-common.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-gd.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-json.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-mbstring.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-mysqlnd.x86_64 0:7.2.17-1.el7.remi will be erased
---> Package php-pdo.x86_64 0:7.2.17-1.el7.remi will be erased
.
.
.
Removed:
php.x86_64 0:7.2.17-1.el7.remi php-cli.x86_64 0:7.2.17-1.el7.remi
php-common.x86_64 0:7.2.17-1.el7.remi php-gd.x86_64 0:7.2.17-1.el7.remi
php-json.x86_64 0:7.2.17-1.el7.remi php-mbstring.x86_64 0:7.2.17-1.el7.remi
php-mysqlnd.x86_64 0:7.2.17-1.el7.remi php-pdo.x86_64 0:7.2.17-1.el7.remi
php-pecl-mcrypt.x86_64 0:1.0.2-2.el7.remi.7.2 php-pecl-zip.x86_64 0:1.15.4-1.el7.remi.7.2
php-xml.x86_64 0:7.2.17-1.el7.remi
Disable the php 7.2v and enable the php7.3v.Install the php modules of 7.3v as well.
[root@linuxhelp ~]# yum --disablerepo=remi-php72 --enablerepo=remi-php73 install php php-gd php-mbstring php-mysql php-curl php-mcrypt
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* epel: mirror.premi.st
* extras: centos.myfahim.com
* remi-php73: rpms.remirepo.net
* remi-safe: rpms.remirepo.net
* updates: centos.myfahim.com
remi-php73 | 3.0 kB 00:00:00
remi-php73/primary_db | 196 kB 00:00:02
.
.
.
Installed:
php.x86_64 0:7.3.5-1.el7.remi php-common.x86_64 0:7.3.5-1.el7.remi
php-gd.x86_64 0:7.3.5-1.el7.remi php-mbstring.x86_64 0:7.3.5-1.el7.remi
php-mysqlnd.x86_64 0:7.3.5-1.el7.remi php-pecl-mcrypt.x86_64 0:1.0.2-2.el7.remi.7.3
Dependency Installed:
oniguruma5.x86_64 0:6.9.1-1.el7.remi php-cli.x86_64 0:7.3.5-1.el7.remi
php-json.x86_64 0:7.3.5-1.el7.remi php-pdo.x86_64 0:7.3.5-1.el7.remi
Complete!
check the version of PHP again.
[root@linuxhelp ~]# php -v
PHP 7.3.5 (cli) (built: Apr 30 2019 08:37:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
Downgrade from 7.3v to 5.6v:
Query and list the rpm packages of php
[root@linuxhelp ~]# rpm -qa | grep php
php-pdo-7.3.5-1.el7.remi.x86_64
php-mysqlnd-7.3.5-1.el7.remi.x86_64
php-json-7.3.5-1.el7.remi.x86_64
php-pecl-mcrypt-1.0.2-2.el7.remi.7.3.x86_64
php-mbstring-7.3.5-1.el7.remi.x86_64
php-7.3.5-1.el7.remi.x86_64
php-cli-7.3.5-1.el7.remi.x86_64
php-common-7.3.5-1.el7.remi.x86_64
php-gd-7.3.5-1.el7.remi.x86_64
Remove the php installed packages of 7.3v.
[root@linuxhelp ~]# yum remove "php-*" -y
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-cli.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-common.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-gd.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-json.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-mbstring.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-mysqlnd.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-pdo.x86_64 0:7.3.5-1.el7.remi will be erased
---> Package php-pecl-mcrypt.x86_64 0:1.0.2-2.el7.remi.7.3 will be erased
--> Finished Dependency Resolution
.
.
.
.
Removed:
php.x86_64 0:7.3.5-1.el7.remi php-cli.x86_64 0:7.3.5-1.el7.remi
php-common.x86_64 0:7.3.5-1.el7.remi php-gd.x86_64 0:7.3.5-1.el7.remi
php-json.x86_64 0:7.3.5-1.el7.remi php-mbstring.x86_64 0:7.3.5-1.el7.remi
php-mysqlnd.x86_64 0:7.3.5-1.el7.remi php-pdo.x86_64 0:7.3.5-1.el7.remi
php-pecl-mcrypt.x86_64 0:1.0.2-2.el7.remi.7.3
Complete!
Disable the 7.3version and enable the 56 version .Install the php modules of 5.6 version as well.
[root@linuxhelp ~]# yum --disablerepo=remi-php73 --enablerepo=remi-php56 install php php-gd php-mbstring php-mysql php-curl php-mcrypt
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* epel: mirror.premi.st
* extras: centos.myfahim.com
* remi-php56: rpms.remirepo.net
* remi-php72: rpms.remirepo.net
* remi-safe: rpms.remirepo.net
* updates: centos.myfahim.com
remi-php56 | 3.0 kB 00:00:00
remi-php56/primary_db | 246 kB 00:00:02
.
.
.
Installed:
php.x86_64 0:5.6.40-8.el7.remi php-common.x86_64 0:5.6.40-8.el7.remi
php-gd.x86_64 0:5.6.40-8.el7.remi php-mbstring.x86_64 0:5.6.40-8.el7.remi
php-mcrypt.x86_64 0:5.6.40-8.el7.remi php-mysqlnd.x86_64 0:5.6.40-8.el7.remi
Dependency Installed:
php-cli.x86_64 0:5.6.40-8.el7.remi php-pdo.x86_64 0:5.6.40-8.el7.remi
php-pecl-jsonc.x86_64 0:1.3.10-2.el7.remi.5.6 php-pecl-zip.x86_64 0:1.15.4-1.el7.remi.5.6
t1lib.x86_64 0:5.1.2-14.el7
Complete!
Check the version of PHP now.
[root@linuxhelp ~]# php -v
PHP 5.6.40 (cli) (built: Apr 30 2019 11:35:35)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Therefore, you have both upgraded and downgraded your PHP version on CentOS 7.6.
Comments ( 0 )
No comments available