Enabling PHP 5.6 and Opcache on CentOS 7

Enabling PHP 5.6 and Opcache on CentOS 7

CentOS is a conservative server operating system, choosing stability over features. Because of this the major versions of PHP it usually includes are several numbers behind the current release.

However, there are plenty of good third party repository out there that provide newer releases for these packages.

To be able to use Opcache (PHP’s new bundled cache system, a replacement for the old APC module) you will need to be running at least PHP 5.5. At present the latest available PHP version on CentOS 7 is 5.4, so it will be necessary to update PHP from a third party repository – Remi’s is a very good alternative source for newer PHP and MySQL on CentOS.

Remi’s packages depend on some EPEL packages, so you should start with installing this external repository first:
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Then continue to install Remi’s repo
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Install yum-utils (contains yum-config-manager which we use next):
yum -y install yum-utils
Enable the PHP 5.6 repo
yum-config-manager --enable remi-php56
And proceed to update PHP to 5.6
yum -y update
Check that PHP is updated with
php -v
Also restart the webserver and check that all sites are still functional.

It is now time to install PHP Opcache, which is as simple as
yum -y install php-opcache
One more webserver restart will be necessary to apply the change.

Leave a Reply