Upgrade PHP 5 to PHP 7 on CentOS/RHEL 6/7

by | 29 Dec 2015 | CentOS, Linux, OS, PHP, Programming, RHEL, Technology | 0 comments

As we all know, PHP 7 brings 2x the increase in performance to PHP powered systems. The main purpose of this guide will be focusing on the steps to upgrade your web server from PHP 5 to PHP 7 on CentOS.

Pre-requisite

If you are upgrading an existing system to PHP 7, it is advised to test your current system with this upgrade on a separate web server.

Check that your current PHP source codes is compatible with PHP 7 at the following link.

https://secure.php.net/manual/en/migration70.php

1. Install YUM Repository

CentOS/RHEL 7.x

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

1. Upgrade PHP

yum install yum-plugin-replace
yum replace php-common --replace-with=php70w-common

2. Install PHP 7

yum install php70w php70w-opcache

[Optional] APC

If you have existing APC (Alternative PHP Cache) installed in your web server, you will have to remove it as APC does not support PHP 7.

pecl uninstall apc

After uninstalling APC, modify the following file.

nano /etc/php.d/apc.ini

Comment the following line of code by adding a semicolon ‘;’ in front of it.

;extension=apc.so

Check PHP Version

Run the following command to check your current version of PHP.

php --version

You should see the following.

PHP 7.0.0 (cli) (built: Dec  2 2015 21:42:51) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

 

That’s it! You are done upgrading from PHP 5 to PHP 7.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Posts

APCCentOSFedoraLinuxOSPHPProgrammingServerTechnology
Install APC (Alternative PHP Cache) in CentOS 5/6/7 and Fedora 20/21

Install APC (Alternative PHP Cache) in CentOS 5/6/7 and Fedora 20/21

APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes. 1. Install Dependency Packages for APC yum install php-pear php-devel httpd-devel pcre-devel gcc make -y 2. Install APC using PECL (PHP Extension Community Library) pecl install apc...