Join to Get Free Linux Server Hacks & cPanel Tips

Install / Upgrade to PHP 7.1 on CentOS 7 / RHEL 7 using Remi RPM Repo

Install / Upgrade to PHP 7.1 on CentOS 7 / RHEL 7 using Remi RPM Repo
5 (100%) 1 vote

Days ago I had to upgrade to PHP 7.1 on the nixcp.com server, it was a major upgrade since I was running PHP 5.6.x.

This was on the top of my todo list after I read that PHP 7.1 was 20% faster than PHP 7.0 (and we all know PHP 7.0 is around twice as fast as PHP 5.6.x), as I am obsessed with web speed and web performance, this was the chance to test PHP 7.1 and its benefits.

Install PHP 7.1 on CentOS 7 Step by Step

After I researched if all my PHP apps were compatible, I started the upgrade process from PHP 5.6.x to PHP 7.1 on CentOS 7.x 64 bits. This is the procedure I used on my server.

Get a list of all your current PHP Packages, just in case:

rpm -qa | grep php

It should look similar to this:

[root@server.nixcp.com:~]rpm -qa | grep php
php-common-5.6.30-1.el7.remi.x86_64
php-pear-1.10.3-1.el7.remi.noarch
php-pecl-memcache-3.0.8-4.el7.remi.5.6.x86_64
php-devel-5.6.30-1.el7.remi.x86_64
php-mysqlnd-5.6.30-1.el7.remi.x86_64
php-mcrypt-5.6.30-1.el7.remi.x86_64
php56-php-common-5.6.30-1.el7.remi.x86_64
php-cli-5.6.30-1.el7.remi.x86_64
php-pecl-jsonc-devel-1.3.10-2.el7.remi.5.6.x86_64
php-pecl-igbinary-2.0.1-1.el7.remi.5.6.x86_64
php-gd-5.6.30-1.el7.remi.x86_64
php-mbstring-5.6.30-1.el7.remi.x86_64
php56-runtime-2.1-5.el7.remi.x86_64
php56-php-pecl-msgpack-0.5.7-1.el7.remi.x86_64
php-5.6.30-1.el7.remi.x86_64
php-pecl-jsonc-1.3.10-2.el7.remi.5.6.x86_64
php-xml-5.6.30-1.el7.remi.x86_64
php-process-5.6.30-1.el7.remi.x86_64
php-xcache-3.2.0-1.el7.remi.5.6.x86_64
php-pecl-memcached-2.2.0-3.el7.remi.5.6.x86_64
php-soap-5.6.30-1.el7.remi.x86_64
php-opcache-5.6.30-1.el7.remi.x86_64
php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64
php56-php-pecl-igbinary-2.0.1-1.el7.remi.x86_64
php-pdo-5.6.30-1.el7.remi.x86_64
php-fpm-5.6.30-1.el7.remi.x86_64
php56-php-pecl-zip-1.13.5-1.el7.remi.x86_64
php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64
php-pecl-msgpack-0.5.7-1.el7.remi.5.6.x86_64
php-xmlrpc-5.6.30-1.el7.remi.x86_64
[root@server.nixcp.com:~]

Install Remi Repo for CentOS 7.x

I already had Remi’s repo installed, but if you don’t, you can do it using this commands:

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

After that, enable PHP-71 packages from your Remi repo, run this command:

yum-config-manager --enable remi-php71

Expected outpout:

[root@server.nixcp.com:~]yum-config-manager --enable remi-php71
Loaded plugins: fastestmirror, langpacks
==== repo: remi-php71 =======
[remi-php71]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl =
cache = 0
cachedir = /var/cache/yum/x86_64/7/remi-php71
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = True
enablegroups = True
...
...
...

Then run yum update:

yum update -y

If you are not upgrading, and just want to install PHP 7.1 on CentOS 7, just run:

yum install php php-devel php-gd php-mbstring php-mcrypt php-soap php-mysqlnd

It should update all your current PHP packages to PHP 7.1, as you see below:

Upgrade / Install PHP 7.1 on CentOS 7 result

If you get this issue:

You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
php-5.6.30-1.el7.remi.x86_64 has missing requires of httpd-mmn = ('0', '20120211x8664', None)

It can be fixed by installing httpd package, which I don’t use but it is required:

yum install httpd -y

After that I disabled httpd from the boot process to ensure it won’t try to boot along with Nginx and cause a port 80 conflict:

systemctl disable httpd

Remove Xcache, because as far as I see it is not available for PHP 7.1.x

yum remove php-xcache* -y

If you preserve Xcache it may lead into a yum error as you see below:

--> Finished Dependency Resolution
Error: Package: 1:php-xcache-3.2.0-1.el7.remi.5.6.x86_64 (@remi-php56)
Requires: php(zend-abi) = 20131226-64
Removing: php-common-5.6.30-1.el7.remi.x86_64 (@remi-php56)
php(zend-abi) = 20131226-64
Updated By: php-common-7.1.3-1.el7.remi.x86_64 (remi-php71)
php(zend-abi) = 20160303-64
Available: php-common-5.4.16-42.el7.x86_64 (base)
php(zend-abi) = 20100525-64
Available: php-common-5.6.29-1.el7.remi.x86_64 (remi-php56)
php(zend-abi) = 20131226-64
Available: php-common-7.1.2-1.el7.remi.x86_64 (remi-php71)
php(zend-abi) = 20160303-64
Error: Package: 1:php-xcache-3.2.0-1.el7.remi.5.6.x86_64 (@remi-php56)
Requires: php(api) = 20131106-64
Removing: php-common-5.6.30-1.el7.remi.x86_64 (@remi-php56)
php(api) = 20131106-64
Updated By: php-common-7.1.3-1.el7.remi.x86_64 (remi-php71)
php(api) = 20160303-64
Available: php-common-5.4.16-42.el7.x86_64 (base)
php(api) = 20100412-64
Available: php-common-5.6.29-1.el7.remi.x86_64 (remi-php56)
php(api) = 20131106-64
Available: php-common-7.1.2-1.el7.remi.x86_64 (remi-php71)
php(api) = 20160303-64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

One thing I noticed: a few packages are still from PHP 5.6 version:

[root@server.nixcp.com:~]rpm -qa | grep php56
php56-php-common-5.6.30-1.el7.remi.x86_64
php56-runtime-2.1-5.el7.remi.x86_64
php56-php-pecl-msgpack-0.5.7-1.el7.remi.x86_64
php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64
php56-php-pecl-igbinary-2.0.1-1.el7.remi.x86_64
php56-php-pecl-zip-1.13.5-1.el7.remi.x86_64

Remove those and install the 7.1 versions from Remi:

yum remove php56*
yum install yum install php71-php-common php71-runtime php71-php-pecl-msgpack php71-php-pecl-jsonc php71-php-pecl-igbinary php71-php-pecl-zip

And the upgrade from PHP 5.6 to PHP 7.1 was complete.

Finally, ensure you restart your http and php-fpm to apply changes:

systemctl restart nginx
systemctl restart php-fpm

That’s all, now you know how to upgrade or install PHP 7.1 on CentOS 7. Please let me know if you have any questions or problems following this tutorial.