The Zend OpCache provides faster PHP execution through opcode caching and optimization. It improves PHP performance by storing precompiled script bytecode in the shared memory.
Installing Zend OPCache on PHP 5.3 or 5.4
1. Login to SSH on your server
2. Type the following commands:
#cd /usr/local/src
#wget http://pecl.php.net/get/ZendOpcache
# to get the latest (master) build do the following instead:
# wget https://github.com/zendtech/ZendOptimizerPlus/archive/master.zip
#tar -xvfz ZendOpcache
#cd zendopcache-7.x.x
#phpize
#whereis php-config
# set the path below
#./configure –with-php-config=/usr/local/bin/php-config
#make
#make install
3. Wait for the installation to complete. At the end it will tell you the location it has placed the file opcache.so. Ensure you have this location to your clipboard.
4. Type: vi /usr/local/lib/php.ini
5. Scroll down until you find the listing extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-XXXXXXXX”
6. Paste this in on a new line (make sure you replace the INSTALL LOCATION with the correct location from step 3):
zend_extension=/INSTALL LOCATION/opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
If xcache is installed, you should also comment all the xcache lines by putting a ; in front of them.
7. Save and exit
8. Type: service httpd restart
9. Type: php -v
10. This should show you that Zend OPcache is enabled.
PHP 5.4.3 (cli) (built: Jan 12 2014 20:27:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by
Zend Technologies
If you require help, contact SupportPRO Server Admin