The Zend OPcache module (formerly known as Zend Optimizer+) provides faster PHP execution through opcode caching and optimization. It improves PHP performance by storing pre-compiled script bytecode in the shared memory. This eliminates the stages of reading code from the disk and compiling it on future access. In addition, it applies a few bytecode optimization patterns that make code execution faster.
Note: Using a PHP optimizer can be especially beneficial for improving Enterprise features such as the auto-complete functionality of adding tags to a Web article. See About adding tags to Web articles.
How it works
PHP is an interpreted language. This means that each time a PHP generated page is requested, the server must read in the various files needed and "compile" them into something the machine can understand (opcode). A typical web page requires more than a dozen of these bits of code to be compiled. Opcode cache mechanisms preserve this generated code in cache so that it only needs to be generated once to serve hundreds or millions of subsequent requests. Enabling opcode cache will reduce the time it takes to generate a page by up to 90%.
Why Zend OPcache?
Although many different opcode cache modules are available — such as XCache, eAccelerator and APC — WoodWing has decided to go for Zend OPcache because of the following reasons:
- Tests have shown us that this optimizer is by far the fastest out there
- It is available as open source
- It is integrated by default in PHP 5.5
Installation
The steps for installing Zend OPCache vary depending on the version of PHP that is used.
On macOS
Info: Running Enterprise Server 10 on macOS is only supported on Enterprise Server version 10.8 or lower.
Installation on Mac OS can be done by building the PHP module manually, by using PECL, or by using alternative repositories such as MacPorts.
Because the MAMP package does not include the PHP header files, the Zend OPcache modules cannot be build properly with this package. This means that building this extension for MAMP is not possible. Note however that having Zend OPcache installed is not essential for running Enterprise Server.
Important: Use of MAMP/WAMP/LAMP not supported
MAMP, WAMP or LAMP are single-distribution packages for Mac OS, Windows or Linux that combine the installation of Apache, PHP, and MySQL. These make them potentially ideal for quickly setting up a new Enterprise Server environment. However, such packages are meant for development purposes and are not to be used in live production environments.
The use of MAMP, WAMP or LAMP for installing an Enterprise Server environment is therefore not supported.
Note: Building the module requires Xcode and the Xcode command line utils to be installed.
Tip:The command line utils can be installed from within Xcode by opening the preferences and choosing Downloads.
Step 1. (Optional, only for a manual installation) Download the latest available version of Zend OPcache by doing the following:
Step 1a. Visit https://github.com/zendtech/ZendOptimizerPlus/releases.
Step 1b. Download the archive.
Step 1c. Extract the downloaded archive.
Step 1d. Access the extracted directory through the Terminal.
Step 2. Choose the method to install the module:
- Execute the following commands:
phpize
Tip: When multiple PHP installations exist on your machine, use the full path, such as /opt/local/bin/phpize
.
./configure --with-php-config=php-config
Tip: When multiple PHP installations exist on your machine, use the full path, such as ./configure --with-php-config=/opt/local/bin/php-config
.
make
make install
- Execute the following command:
sudo pecl install zendopcache-x.x.x
Note: Replace x.x.x. with the version number of the module.
Example: Here, Zend OPcache version 7.0.2 is installed:
|
Step 3. Update the php.ini file by adding the following line:
zend_extension = <path_to>/opcache.so
Notes:
|
Step 4. Add the following recommended settings to the php.ini file:
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
MacPorts already provides the Zend module.
Step 1. Do the one of the following:
For PHP 5.3:
sudo port install php-opcache
or:
sudo port install php53-opcache
For PHP 5.4:
sudo port install php54-opcache
Step 2. The php.ini file should be automatically updated. In case the Xdebug module is also loaded, make sure that the OPcache module is loaded before Xdebug by manually modifying the order of the modules in the php.ini file.
Step 3. Add the following recommended settings to the php.ini file:
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
On Windows
Installation on Windows needs to be done manually. For instructions, please visit http://us2.php.net/manual/en/opcache.installation.php.
Notes:
|
On Linux
Installation on Linux can be done by using the PHP developer packages, by building the PHP module manually, by using PECL, or by using alternative repositories such as EPEL.
Step 1. (Optional, only for a manual installation) Download the latest available version of Zend OPcache by doing the following:
Step 1a. Visit https://github.com/zendtech/ZendOptimizerPlus/releases.
Step 1b. Download the archive.
Step 1c. Extract the downloaded archive.
Step 1d. Access the extracted directory through the Terminal.
Step 2. Choose the method to install the module:
Step 2a. Install the PHP developer packages by doing one of the following:.
- For RHEL:
sudo yum install php-devel
- For Debian:
sudo apt-get install php5-dev
- For OpenSUSE:
sudo zypper install php5devel gcc make
Note: OpenSUSE needs access to gcc to build the extension.
Step 2b. Execute the following commands:
phpize
Tip: When multiple PHP installations exist on your machine, use the full path, such as /usr/bin/phpize
.
./configure --with-php-config=php-config
Tip: When multiple PHP installations exist on your machine, use the full path, such as ./configure --with-php-config=/usr/bin/php-config
make
make install
- Execute the following commands:
For RHEL:
sudo yum install php-devel
sudo yum install php-pear
sudo pecl install zendopcache-x.x.x
Note: Replace x.x.x. with the version number of the module.
Example: Here, Zend OPcache version 7.0.2 is installed:
|
For Debian:
sudo apt-get install php5-dev
sudo apt-get install php5-pear
sudo pecl install zendopcache-x.x.x
Note: Replace x.x.x. with the version number of the module.
Example: Here, Zend OPcache version 7.0.2 is installed:
|
For OpenSUSE:
sudo zypper install php5devel gcc make
sudo zypper install php5-pear
sudo pecl install zendopcache-x.x.x
Note: Replace x.x.x. with the version number of the module.
Example: Here, Zend OPcache version 7.0.2 is installed:
|
Note:OpenSUSE needs access to gcc to build the extension.
Step 3. Update the php.ini file by adding the following line:
zend_extension = <path_to>/opcache.so
Notes:
|
Step 4. Add the following recommended settings to the php.ini file:
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
EPEL (available in Red Hat and other RHEL based Linux operating systems) already provides the Zend module.
Note: For more information about EPEL, visit https://fedoraproject.org/wiki/EPEL.
Step 1. Execute the following command:
sudo yum install php-pecl-zendopcache
Step 2. The php.ini file should be automatically updated. In case the Xdebug module is also loaded, make sure that the OPcache module is loaded before Xdebug by manually modifying the order of the modules in the php.ini file.
Step 3. Add the following recommended settings to the php.ini file:
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
OPCache is enabled by default In PHP 5.5 unless PHP is compiled with the --disable-all
option.
When this is the case, OPCache can be enabled by compiling PHP with the --enable-opcache
option.
Note: For more information, see the PHP documentation OPCache installation.
Comment
Do you have corrections or additional information about this article? Leave a comment! Do you have a question about what is described in this article? Please contact Support.
0 comments
Please sign in to leave a comment.