skip to Main Content

This tutorial will show you how to upgrade PHP 5.4 to PHP 7.0 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

Cool, 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=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

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

Enable the Remi PHP7.0 Repository:

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

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

[remi-php70]
name=Remi's PHP 7.0 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php70/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php70/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php70/mirror
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 7.0

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 7.0 installed:

php -v

Output should look like:

PHP 7.0.32 (cli) (built: Sep 11 2018 13:20:19) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

Sweet deal, upgrade is done!!

Sponsored Links

This Post Has 0 Comments

Don't be shy, leave a reply!