Installing Zend OPcache on PHP 5.4 for cPanel Servers

In this guide you must be comfortable in editing your server using SSH. At Carbon Hosting we like to use WINSCP & Putty to log into the server to edit files and run commands.

Zend OPcache is a PHP accelerator that provides faster PHP execution through opcode caching and optimization, it is now the default PHP accelerator in PHP5.5 but you can still install it in PHP5.4 

Install Zend OpCache (for PHP 5.3 or 5.4 only)

Log into your server using Putty, and copy and paste the following commands

cd /usr/local/src
tar xvfz ZendOpcache
cd ZendOpcache
whereis php-config
NOTE: the path /usr/local/bin/php-config is displayed.
./configure --with-php-config=/usr/local/bin/php-config
make install
NOTE:the install path it should be like this /usr/local/lib/php/extensions/no-debug-non-zts-20100525/

Using WINSCP edit /usr/local/lib/php.ini
SEARCH ; Directory in which the loadable extensions (modules) reside.
Paste the path from the above step.

zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20100525/"

Then paste the following code at the bottom of the file so you can easily find it


Save the file.

Use Putty for the Magic to happen!

service httpd restart
php -v

You should get the following message.

PHP 5.4.38 (cli) (built: Mar 16 2015 10:36:07)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader v4.6.1, Copyright (c) 2002-2014, by ionCube Ltd., and
with Zend OPcache v7.0.4, Copyright (c) 1999-2014, by Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

If you get a problem make sure your path to zend_extension = is correct. If this is incorrect you will get the following message and result in a 500 server error.

Failed loading cannot open shared object file

Or if you want to disable Zend Opcache , comment out using a ; as shown below in php.ini

;zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20100525/"

Run the restart command again

service httpd restart
php -v

So you have followed my instructions for installing and configuring PHP Zend OPcache, Now you need to check that its actual working. So how do you check if Zend OPcache is working/caching?

Install AMNUTS Opcache GUI

To use git is really easy. In putty go to the directory of public_html.

yum install git
git clone

This command will now clone the opcache-gui to your public_html/opcache-gui folder, but be aware that you will need to password protect this directory.

Please consider sharing this post.

Leave a Reply