Setting up Zend Optimizer+ – php5-opcache – on Raspberry Pi with Raspian

Now the Raspberry Pi doesn’t come with the opcache as a package. Well, at least I couldn’t find it. So I compiled it, and it was relatively easy and fast!

I did all this as root, I’m 90% sure you need to be, but you could try as the pi user and see what happens. But anyway, log in on the command line and $ sudo -i to get an interactive superuser prompt.

I’m assuming you have a webserver (nginx or apache) installed and set up using php-fpm.

First install php development tools and git. $ apt-get install php5-dev git

Now download the source.

$ git clone https://github.com/zendtech/ZendOptimizerPlus.git

$ cd ZendOptimizerPlus

The next command phpizes your downloaded source, it customises a few things to make it work with your install.

$ phpize

Configure!

$ ./configure --with-php-config=/usr/bin/php-config

Compile!

$ make -j 2

Install!

$ make install

Make a note of the directory it installs into. I’m assuming you’re using the php-fpm way of doing things, but if not, adjust accordingly.

Now get your favourite code editor up and edit: /etc/php5/fpm/conf.d/20-opcache.ini

Pop this into that file:

zend_extension=--the directory you noted down--/opcache.so

opcache.memory_consumption=32
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60 #set this to 0 if running a development server
opcache.fast_shutdown=1
opcache.enable_cli=1

Now restart php. $ service php5-fpm restart

And you’re done. One php opcache. Speedy!

Leave a Reply

Your email address will not be published. Required fields are marked *