How to install the ZendOptimizerPlus (aka OPcache) PHP extension with older PHP versions (5.2.x, 5.3.x, 5.4.x)

  • How to install the ZendOptimizerPlus (aka OPcache) PHP extension for older PHP versions (5.2x, 5.3.x, 5.4.x)

    ZendOptimizerPlus (OPcache) is an opcode cache which is already part of PHP5.5. If you are using an older PHP version, it can be interesting to install it on your server.

    Installation of required package

    1. # aptitude install php5-dev

    Download of the upstream source (here, I'm using the last master branch state)

    1. # cd /usr/local/src# mkdir opcache && cd opcache# wget

    Unzip of the upstream source

    1. # unzip cd ZendOptimizerPlus-master

    Configuration, compilation and installation

    1. # phpize# ./configure --with-php-config=/usr/bin/php-config# make && make install

    Last output should be (which give you the path of the opcache extension)

    1. Installing shared extensions: /usr/lib/php5/20100525+lfs/

    Creation of the file /etc/php5/mods-available/opcache.ini with the following content

    1. zend_extension=/usr/lib/php5/20100525+lfs/

    Activation of the OPcache extension

    1. # php5enmod opcache

    Result (here on Ubuntu Raring)

    1. root@raring:/usr/local/src/opcache# php5 -v
    2. PHP 5.4.9-4ubuntu2.4 (cli) (built: Dec 12 2013 04:26:30)
    3. Copyright (c) 1997-2012 The PHP Group
    4. Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    5. with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

    Note: The OPcache extension helps to speed up PHP applications, but also, this allow to reduce the memory usage. For instance, during my tests, the memory used for the panel (which was run through Nginx and PHP5.4.9 as a FastCGI application) has been halved.

    Enjoy ;)


  • @remontti

    You are kidding?

    It's clearly stated in the howto that the opcache.ini file must be created. Next time follow the step correctly and this will work.

    Creation of the file /etc/php5/mods-available/opcache.ini with the following content
    Source Code