Page tree
Skip to end of metadata
Go to start of metadata

Introduction

Normally PHP scripts are compiled at runtime, each time you request a page this will happen again, this is where opcache comes in, opcache caches the compiled bytecode, so any subsequent request will not require a complete compile of all the requested PHP code.

For PHP applications which contain a lot of PHP code like the WebApp or Z-Push it is highly recommended to enable opcache, as this can speed up the loading of pages substantially and lower the web server load as well.

Opcache is usually included with PHP 5.5.0 and later and therefore it is included in most distributions.

Enabling opcache

On certain Distributions which ship PHP 5.5.0 or higher opcache is already enabled by default, for example this is the case with Debian 8, Ubuntu 14.04 and Ubuntu 16.04

On Rhel/CentOS systems with rh-php56 or rh-php70* from the Software Collections installed, it is required to install the respective rh-php56-php-opcache or rh-php70-php-opcache package in order the enable opcache.

On SLES it is required to install the php5-opcache package.

If you are on PHP 5.2.0 or higher you can also build opcache yourself, see the following page for the tarballs https://pecl.php.net/package/ZendOpcache

* Note: Kopano does not provide an MAPI module for rh-php70 at this time.

Examples

Centos with SCL

To enable opcache on CentOS 6 or CentOS 7 with httpd24-httpd and rh-php56 installed.

# yum install rh-php56-php-opcache -y

After this it is required to restart Apache to activate the opcache module.

# service httpd24-httpd restart

SLES 12 SP1

To enable opcache on SLES 12 SP1

# zypper install php5-opcache

After this it is required to restart Apache to activate the opcache module.

# service apache2 restart

Further information

For more information about PHP opcache please visit http://php.net/manual/en/book.opcache.php at php.net.

Alternatives

For older PHP versions you might look into to following opcode caching modules, which might be included in your Linux Distribution.

  • No labels