Upgrading PHP to 5.6.x or later on CentOS7 via Yum and the IUS repo

June 05, 2017

CentOS7 (and some of the other RHEL flavours) currently don't include PHP 5.6+ in the core repos, and yet the versions of PHP bundled are at EOL or close to it.

A number of guides suggest using the webstatic or remi repos - but this is not recommended as they contain packages with names that conflict with packages in core repos.

One of the better options is to use the IUS repo (Inline with Upstream Stable project), which means you can quickly and easily update.

First, install the IUS rep (you will need the EPEL repo if you haven't got it already)

yum install https://centos7.iuscommunity.org/ius-release.rpm

Next, we install, then use yum-plugin-replace to replace the existing PHP package

yum install yum-plugin-replace
yum replace --replace-with php56u php

Finally httpd should be restarted, and you should be good to go

service httpd restart

DigitalOcean has a more detailed post on installing PHP7 from the same repo.


Profile picture

From Dave, who writes to learn things. Thoughts and views are his own.

© 2024, withdave.