making bbPress (and WordPress) work better!

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:

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:

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:


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:

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


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

So just copy them there

cp /temp/usr/local/zend/lib/ /usr/lib64/php/modules/
cp /temp/usr/local/zend/lib/optimizerplus/php-5.4.x/ /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 =
; extension =
; extension=
(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_extension = /usr/lib64/php/modules/  
zend_extension = /usr/lib64/php/modules/

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.validate_timestamp=0         ; file stat
zend_optimizerplus.revalidate_freq=2    ; seconds
zend_optimizerplus.interned_strings_buffer=16   ; default 4 - undocumented?
zend_optimizerplus.max_wasted_percentage=25     ; percent waste until restart

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:

Find out more about Zend Optimizer Plus functions to control from php code here:

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>';}

9 responses

  1. Reblogged this on ITechonology.

    February 14, 2013 at 1:08 am

  2. 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

  3. Pingback: How to Boost WordPress Performance Drastically with Zend Optimizer+

  4. Pingback: PHP 5.5 to be delayed so Optimizer Plus can be built-in | _ck_ says...

  5. Anonymous

    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 for a later version of Zend Op

    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

      March 13, 2013 at 10:39 am

  6. Any chance you can guide me with this via priv?

    May 29, 2013 at 11:22 am

  7. Igor

    Thanks for sharing, have successfully installed Zend Optimizer and Opcode Cache on my CentOS combining yours and the guide bewlow.

    March 7, 2014 at 1:43 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s