1. Home
  2. Linux
  3. Upgrading PHP 5.x to PHP 7.0 on CentOS/RedHat server using Yum

Upgrading PHP 5.x to PHP 7.0 on CentOS/RedHat server using Yum

From our earlier posts, you would have seen How to upgrade to php-5.5 using remi repository. Today we shall see How to Upgrade PHP to it’s latest version 7.0 from 5.5 through the same Remi repository using YUM. RPM of the latest version of PHP are available in remi-php70 repo.  WARNING: This remi-php70 repo upgrade is only available for RHEL/CentOS version equal to or above 6. This tutorial will tell you how to setup Remi repo to install PHP 7.0.

Step1: How to configure latest Remi repository in CentOS/Fedora/RHEL

Firstly, we need to add the correct Remi repository and enable Remi update, remi release and remi-php70 repository: Go to /etc/yum.repos.d/ directory and download the latest remi repo file:

# wget http://rpms.famillecollet.com/enterprise/remi.repo

By default, other Remi repository would be disabled. If you want to enable it permanently, open the file /etc/yum.repos.d/remi.repo and change the value of enabled from 0 to 1. Upgrade PHP on CentOS

Step 2: Install/Upgrade PHP to version 7.0

Firstly remove the older php installation using yum remove command as shown below:

# yum remove php php-cgi php-cli php-common

Stop the Apache2 service

# service httpd stop

Now install PHP 7.0 using remi-php70 repo:

# yum --enablerepo=remi-php70 install php

Sample output:

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * 
base: centos.excellmedia.net *
extras: centos.excellmedia.net *
remi-php70: mirrors.thzhost.com *
remi-safe: mirrors.thzhost.com *
updates: centos.excellmedia.net
Setting up Install Process
Resolving Dependencies -->
Running transaction check --->
Package php.x86_64 0:7.0.1-1.el6.remi will be installed
:::::::::::::::::::: ::::::::::::::::::::
Installed: php.x86_64 0:7.0.1-1.el6.remi
Dependency Installed:
php-cli.x86_64 0:7.0.1-1.el6.remi    
php-common.x86_64 0:7.0.1-1.el6.remi
php-json.x86_64 0:7.0.1-1.el6.remi
Complete!

Step3: Verify PHP Version

Verify the latest installed php version using below command:

# php -v
PHP 7.0.1 (cli) (built: Dec 16 2015 15:31:55) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

And you’re done.

Updated on September 2, 2017

Was this article helpful?

Related Articles

Leave a Comment