skip to Main Content

This tutorial will show you how to upgrade PHP 5.4 to PHP 5.6 on CentOS 7.5.

The assumption is that you are running a stock installation of CentOS, and already have PHP 5.4 installed.

 

1. Verify current version of PHP

Type in the following to see the current PHP version:

php -v

The output should match this:

PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Perfect, let’s continue!

 

2. Install the REMI and EPEL repositories

If you don’t already have them, install the Remi and EPEL repositories:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm

Enable the Remi repository globally:

nano /etc/yum.repos.d/remi.repo

Under the section that looks like [remi] make the following changes:

[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Also, under the section that looks like [remi-php55] make the following changes:

[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php56/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php56/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php56/mirror
# NOTICE: common dependencies are in "remi-safe"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Type CTRL-O to save and CTRL-X to close the editor

 

3. Upgrade PHP 5.4 to PHP 5.6

Now we can upgrade PHP. Just type in the following command:

yum -y upgrade php*

Once the upgrade has completed, verify that you have PHP 5.6 installed:

php -v

Output should look like:

PHP 5.6.38 (cli) (built: Oct 24 2018 12:50:38)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Sweet deal, upgrade is done!!

Sponsored Links

Don't be shy, leave a reply!