In the following article we will guide you through the steps on how to install and set-up Zend Optimizer on a CentOS 6 Linux VPS.
Installing Zend OPcache will significantly boost your website’s speed and performance.
How is Zend OPcache able to speed up my website?
The Zend OPcache provides faster PHP execution through opcode caching and optimization. It improves PHP performance by storing pre-compiled script byte-code in shared memory. This eliminates the stages of reading code from disk and compiling it on future access. In addition, it applies a few byte-code optimization patterns that make code execution faster.
Note that this version of Zend OPcache is compatible with PHP 5.2.x, 5.3.x, 5.4.x and PHP-5.5. PHP 5.2 support may be removed in the future though.
UPDATE THE SYSTEM
Before going any further, make sure a screen session is in place and check if your CentOS 6 linux vps is fully up-to-date by running:
## screen -U -S zend-screen ## yum update
INSTALL GIT
Install git
so you’re able to clone Zend Optimizer in your Linux VPS
## yum install git
SET-UP BUILD DIRECTORY
create /opt/build
build directory using mkdir
## mkdir -p /opt/build
CLONE ZEND OPTIMIZER REPOSITORY
Fetch Zend Optimizer from Github using git
in /opt/build/zend-opcache
and navigate there
## git clone https://github.com/zendtech/ZendOptimizerPlus.git /opt/build/zend-opcache ## cd /opt/build/zend-opcache
INSTALL REQUIRED BUILD PACKAGES
Install the required packages needed to successfully build Zend Opcache on the CentOS 6 system.
## yum install php-devel gcc
PREPARE, COMPILE AND INSTALL THE PACKAGE
prepare the extension for compiling using the phpize
command
## phpize
configure the sources using the following command
## ./configure --with-php-config=$(which php-config)
compile the sources using the command below
## make
install opcache.so
into PHP extension directory
## make install
once installed, load the Zend opcache extension by adding the following to /etc/php.d/opcache.ini
## vim /etc/php.d/opcache.ini zend_extension=/usr/lib/php/modules/opcache.so 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
APPLY THE CHANGES
restart for the change to take effect
if using apache:
## service httpd restart
if using php-fpm
## service php-fpm restart
verify Zend opcache is enabled using
## php -v
or create sample info.php
file within your domain’s public document root containing the following
<?php phpinfo();
open it in your browser and search for ‘Zend OPcache’
Of course, if you are one of our Linux VPS Hosting customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will set this up for you immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
Hello,
thanks for your articles first.
on centos 6.6,php 5.3.3, i tried your instructions and before running ‘make install’, i tried ‘make test’.
i got one test failed. the message is below.
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test that script cached info is correct [tests/is_script_cached.phpt]
=====================================================================
i’m not sure if i can continue for ‘make install’.
If there were no errors during the `make` step then you can run `make install`.
Ik receive the follow:
[root@vps zend-opcache]# php -v
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so’ – /usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.4.45 (cli) (built: Dec 2 2015 12:19:02)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@vps zend-opcache]#
Hey Roger, you should open your php.ini file and fix the zend_extension path.