Latest news from 5wire Networks

How to install and configure PHP Zend Opcache

What is Opcache you ask?

Opcache is a PHP extensions that will help to improve server & applications performance. There are many popular opcode caches like eaccelerator, xcache, apc, etc.  Opcache is recommended in almost all App and Server production environments as a method of caching and handling PHP tasks. All you need is disk or memory space in order to store the cached data. If you’re using a VPS, check out our SWAP tutorial.

EPEL Repository Required for Opcache

CentOS 7 (including EPEL install)

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm

If you already have EPEL installed:

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

CentOS 6 (including EPEL install)

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

If you already have EPEL installed:

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

Install Zend Opcache on CentOS / RHEL / Fedora

yum install php-opcache

Edit the opcache.ini file:

nano -w /etc/php.d/opcache.ini

The basic configuration currently used on our VPS 0.5 package. You can increase the Max Accelerated Files to a higher number such as 10k if you desire.

; Enable Zend OPcache extension module
zend_extension=opcache.so

; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0

; The OPcache shared memory storage size.
opcache.memory_consumption=128

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=4000

; If enabled, a fast shutdown sequence is used for the accelerated code
opcache.fast_shutdown=1

;following can be commented for production server
opcache.revalidate_freq=0
opcache.consistency_checks=1

Restart Apache or Nginx and Opcache will start to make a difference straight away!