How to manually install the Zend Optimizer Plus Opcode Cache on PHP 5.4
Feb 13 update! Zend Optimizer+ is now officially open source so these instructions to manually install the binary are no longer needed! Go here instead: https://github.com/zend-dev/ZendOptimizerPlus/
I’ve also written a control panel for it which you can find here:
With Zend supposedly open-sourcing their Optimizer+ opcode cache for PHP, likely replacing APC, I want to preview what I might be dealing with and any limitations/advantages.
However I did not want to install a bunch of unknown zend stuff into php slowing it down or causing conflicts, I only wanted the bare minimum and know exactly what I am installing.
Turns out it’s rather easy once you know what to look for.
There is an rpm repo that seems to carry the newest versions of their products here:
http://repos.zend.com/zend-server/6.0/rpm/x86_64/
I am working with linux centos 6.3 on a 64bit platform so that’s the above repo, you may have to adjust as necessary. Just browse upwards in the path for other linux flavors.
Make yourself a temporary directory to muck around in.
mkdir /temp && cd /temp
Fetch these two files:
wget http://repos.zend.com/zend-server/6.0/rpm/x86_64/php-5.4-extension-manager-zend-server-6.0.0-128.x86_64.rpm wget http://repos-source.zend.com/zend-server/6.0/rpm/x86_64/php-5.4-optimizer-plus-zend-server-6.0.0-128.x86_64.rpm
Since they are rpms you could have had them automatically install. However I want to know exactly what is going on so I extracted these two files:
ZendExtensionManager.so
ZendOptimizerPlus.so
You can extract them via 7zip or uzing rpm2cpio.
rpm2cpio php-5.4-extension-manager-zend-server-6.0.0-128.x86_64.rpm | cpio -idmv rpm2cpio php-5.4-optimizer-plus-zend-server-6.0.0-128.x86_64.rpm | cpio -idmv
then the files will be in
/temp/usr/local/zend/lib/ZendExtensionManager.so /temp/usr/local/zend/lib/optimizerplus/php-5.4.x/ZendOptimizerPlus.so
Now to find an appropriate place to put them.
Look in your phpinfo on your server and find the extension_dir setting
in my test case using virtualmin on centos, it was
/usr/lib64/php/modules
So just copy them there
cp /temp/usr/local/zend/lib/ZendExtensionManager.so /usr/lib64/php/modules/ cp /temp/usr/local/zend/lib/optimizerplus/php-5.4.x/ZendOptimizerPlus.so /usr/lib64/php/modules/
Then check your phpinfo again for where php.ini
Loaded Configuration File /etc/php.ini
so edit that file
nano /etc/php.ini
Make sure you turn off any existing opcode caches, you cannot have two!
Probably are listed near the bottom of the file since it’s added on:
; extension = apc.so
; extension = xcache.so
; extension= eaccelerator.so
(you’ll only have one of those, just put a semicolon in front to disable)
Now we need to add the settings for Zend Optimizer Plus
[zend] zend_extension = /usr/lib64/php/modules/ZendExtensionManager.so zend_extension = /usr/lib64/php/modules/ZendOptimizerPlus.so
Obviously change the two paths are required to where you copied them.
Now we need some settings which you can put below that.
I’ve added some custom settings here to tinker with.
zend_optimizerplus.enable=1 zend_optimizerplus.use_cwd=1 zend_optimizerplus.validate_timestamp=0 ; file stat zend_optimizerplus.revalidate_freq=2 ; seconds zend_optimizerplus.revalidate_path=0 zend_optimizerplus.dups_fix=0 zend_optimizerplus.log_verbosity_level=1 zend_optimizerplus.memory_consumption=128 zend_optimizerplus.interned_strings_buffer=16 ; default 4 - undocumented? zend_optimizerplus.max_accelerated_files=2000 zend_optimizerplus.max_wasted_percentage=25 ; percent waste until restart zend_optimizerplus.consistency_checks=0 zend_optimizerplus.force_restart_timeout=60 zend_optimizerplus.blacklist_filename= zend_optimizerplus.fast_shutdown=0 zend_optimizerplus.optimization_level=0xfffffbbf zend_optimizerplus.enable_slow_optimizations=1
These settings are untested and just educated guesses for my needs, you will want to adjust, especially the memory size of 128 megs and note I turned off file stat which not everyone will want to do unless they don’t change php files often.
Then you will need to restart PHP via either restarting apache if you are using mod-php or restarting php-fpm if you are using php as a standalone.
Then you should see a summary section for Zend Optimizer+ inside your phpinfo
with Zend Extension Manager v6.0.0, Copyright (c) 2003-2012, by Zend Technologies with Zend Optimizer+ v6.0.0, Copyright (c) 1999-2012, by Zend Technologies
Find out more about Zend Optimizer Plus directives (for php.ini) here:
http://files.zend.com/help/Zend-Server/content/zendoptimizerplus.html
Find out more about Zend Optimizer Plus functions to control from php code here:
http://files.zend.com/help/Zend-Server/content/zend_optimizer+_-_php_api.htm
Some early observations so far:
Zend doesn’t support a disk model for opcodes, only memory?
Zend has no way to delete a single file from the cache?
Zend does not come with any control panel but you can dump this function to get all sorts of stats that are similar to APC’s available information.
<?php if (function_exists('accelerator_get_status')) {print '<pre>'; print_r(accelerator_get_status()); print '</pre>';}
Reblogged this on ITechonology.
February 14, 2013 at 1:08 am
Seems like the name of the rpm packages for download has changed. Now it’s
zend-server-php-5.3-6.0.0-592.x86_64.rpm or zend-server-php-5.4-6.0.0-483.x86_64.rpm
February 15, 2013 at 5:11 am
Thanks for letting me know. You can also just get the source directly now and easily compile on any flavor of linux: https://github.com/zend-dev/ZendOptimizerPlus/
February 15, 2013 at 5:21 am
Pingback: How to Boost WordPress Performance Drastically with Zend Optimizer+
Pingback: PHP 5.5 to be delayed so Optimizer Plus can be built-in | _ck_ says...
just wondering if you tried installing zend optimizer+ with PHP 5.4.12 using the latest source on github?
I got through most steps but when php -v
Zend Optimizer+ requires Zend Engine API version 220090626.
The Zend Engine API version 220100525 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Op
timizer+.
So basically I ran into problem where zend optimizer+ is asking for an older version of PHP 5.4?
March 13, 2013 at 10:10 am
If you built it from trunk they are constantly fiddling with it lately, you may have to step back a commit or two if they broke it. I actually have a version from earlier this month running on a production server just fine, though I think we are using 5.4.13rc1 http://qa.php.net/
March 13, 2013 at 10:39 am
Any chance you can guide me with this via priv?
May 29, 2013 at 11:22 am
Thanks for sharing, have successfully installed Zend Optimizer and Opcode Cache on my CentOS combining yours and the guide bewlow.
http://www.rosehosting.com/blog/speed-up-nginx-using-ngx_pagespeed-on-a-centos-6-vps/
March 7, 2014 at 1:43 am