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

    Shell-Script
    1. # aptitude install php5-dev


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

    Shell-Script
    1. # cd /usr/local/src# mkdir opcache && cd opcache# wget https://github.com/zendtech/ZendOptimizerPlus/archive/master.zip


    Unzip of the upstream source

    Shell-Script
    1. # unzip master.zip# cd ZendOptimizerPlus-master


    Configuration, compilation and installation

    Shell-Script
    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)

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


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

    Code
    1. zend_extension=/usr/lib/php5/20100525+lfs/opcache.so


    Activation of the OPcache extension

    Shell-Script
    1. # php5enmod opcache


    Result (here on Ubuntu Raring)

    Shell-Script
    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 ;)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @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
    zend_extension=/usr/lib/php5/20100525+lfs/opcache.so

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206