Web Development

Zend Opcache is an open source project that speeds PHP execution by opcode caching and optimization. It works by storing precompiled script bytecode in shared memory. This way, reading code will be eliminated.

Installing Zend Opcache is very easy.

Update Operating System

yum update

If you haven’t updated recently, you might get something like this:

Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink                                                                                                                         |  23 kB     00:00     
 * base: mirrors.clouvider.net
 * epel: mirror.vorboss.net
 * extras: mirror.sov.uk.goscomb.net
 * updates: mirror.sov.uk.goscomb.net
base                                                                                                                                  | 3.7 kB     00:00     
base/primary_db                                                                                                                       | 4.4 MB     00:00     
epel                                                                                                                                  | 4.4 kB     00:00     
epel/primary_db                                                                                                                       | 6.0 MB     00:00     
extras                                                                                                                                | 3.4 kB     00:00     
extras/primary_db                                                                                                                     |  19 kB     00:00     
mod-pagespeed                                                                                                                         |  951 B     00:00     
mod-pagespeed/primary                                                                                                                 | 5.1 kB     00:00   

If you have updated recently, you should get something like this:

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.clouvider.net
 * epel: mirror.vorboss.net
 * extras: mirror.sov.uk.goscomb.net
 * updates: mirror.sov.uk.goscomb.net
Setting up Update Process
No Packages marked for Update

Install Requirements

yum install gcc httpd-devel php-pear pcre-devel

This will install a ton on scripts along with gcc and pear:

  gcc.x86_64 0:4.4.7-4.el6                    httpd-devel.x86_64 0:2.2.15-29.el6.centos                    pcre-devel.x86_64 0:7.8-6.el6                   

Dependency Installed:
  apr-devel.x86_64 0:1.3.9-5.el6_2                     apr-util-devel.x86_64 0:1.3.9-3.el6_0.1                cloog-ppl.x86_64 0:0.15.7-1.2.el6             
  cpp.x86_64 0:4.4.7-4.el6                             cyrus-sasl-devel.x86_64 0:2.1.23-13.el6_3.1            db4-cxx.x86_64 0:4.7.25-18.el6_4              
  db4-devel.x86_64 0:4.7.25-18.el6_4                   expat-devel.x86_64 0:2.0.1-11.el6_2                    glibc-devel.x86_64 0:2.12-1.132.el6           
  glibc-headers.x86_64 0:2.12-1.132.el6                kernel-headers.x86_64 0:2.6.32-431.11.2.el6            mpfr.x86_64 0:2.4.1-6.el6                     
  openldap-devel.x86_64 0:2.4.23-34.el6_5.1            ppl.x86_64 0:0.10.2-11.el6

Install Zend Opcache

yum install php-pecl-zendopcache

This will install Zend Opcache.

Running Transaction
  Installing : php-pecl-zendopcache-7.0.3-1.el6.x86_64                                                                                                   1/1 
  Verifying  : php-pecl-zendopcache-7.0.3-1.el6.x86_64                                                                                                   1/1 

  php-pecl-zendopcache.x86_64 0:7.0.3-1.el6 

Restart Server

You will need to restart your server after installation for this to take effect:

sudo service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Test Installation

PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
    with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH

Now, you will see Zend OPcache installed. Enjoy!