PHP’s Zend Opcache Config & Web Viewer

PHP 5.5. has zend opcache support in core. Since APC is not updated from long time, we made a switch to new Zend Opcache. Below is our config and web-based stats viewer.

PHP’s Zend Opcache Config

In your php.ini or depending on your PHP version

/etc/php5/fpm/conf.d/05-opcache.ini

or /etc/php/7.0/mods-available/opcache.ini

zend_extension=opcache.so
opcache.memory_consumption=512
opcache.max_accelerated_files=50000

;following can be commented for production server
opcache.revalidate_freq=0
opcache.consistency_checks=1

Web Viewer

Unlike APC, for Zend Opcache there are plenty of web-based viewer. May be reason being zend opcache’s official status has something to do with it. Below is list to choose from.

#1. Opcache-Status by Rasmus Lerdorf

This is by PHP creator himself. Very beautiful.

Installation

cd /var/www/example.com/htdocs
wget https://raw.github.com/rlerdorf/opcache-status/master/opcache.php

Screenshot:

rlerdorf-opcache-status

#2. opcache-gui by amnuts

Responsive. Feature-rich. Notably option to enable real-time stats and and option to reset/flush opcache.

If you are going to use this, make sure it is protected by some security layer.

Installation:

cd /var/www/example.com/htdocs/
wget https://raw.github.com/amnuts/opcache-gui/master/index.php -O op.php

Screenshot:

amnuts-opcache-gui

#3. ocp.php by ck-on

Has best way to analyse/explore file-based cache. UI is more old-style.

Installation:

wget https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php

Screenshot:

ck-Opcache-Control-Panel

We are using all 3 for now! We will update this post if we add or remove anything from our list.

27 thoughts on “PHP’s Zend Opcache Config & Web Viewer

  1. Hi i really like your tests on php5.5 wish my shared hosti g had it installed. As well be able to use wordpress with memcached setup to really have a performance boost even tough shared hosting with a cdn setup is really fast.

        1. It’s a KVM based VPS which means you’re getting guaranteed resources. I’m testing the smallest Digital Ocean VPS right now.

          If you want to know what could be missing try Digital Ocean’s UserVoice to see what other people are missing.

  2. It’s actually wise to use one of these web based viewers so you can better adjust cache values, depending on your configuration. I like the live feed of the opcache-gui by amnuts, myself

  3. An interesting set of observations between APC and Zend Opcache which suggests Opcache is a memory hog and not as effective as APC. Just thought I’d go digging a bit

    1. The problem with APC and it’s user cache is that the cache is created n times for n PHP processes like php-fpm or Apache process. If you want to scale you need lots of processes to serve the increasing amount of users. That’s why one cache (e.g. memcache) for n PHP processes is more economically.

  4. i tried most of caching tool to increase my site performance (and reduce my server load) but i wasn’t able to find anything “good”, i have a vps with some site on it (wordpress, custom made cms, and so) and no caching system was good, lastly i tried zend opcache, and it made the load of server dramatically drop, but some thing in wordpress were broken (jetpack stats for example) and a “hand made” site loaded partially and become useless (i guess it is something about ajax, but i have no idea on where to check)… so i reverted, and that is really a pity, because using opcache it was all so fast and i have a real unloaded server…

  5. thank you rahul,
    i tried your suggestion, but all the wp-admin site become useless (page unavailable) with opcache installed, and some other site i host arent working properly; it’s really a pity beacuse on fronte end side, opcache really speed up!

  6. Following your instructions, i updated to php 5.5 and i managed to have this:
    PHP 5.5.9-1+sury.org~precise+1 (cli) (built: Feb 13 2014 15:53:53)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

    thank you thank you thank you

  7. I’m a bit confused here… how to I put some security on these pages? I don’t need everyone being able to see them. How do I limit access to just me, like I did with phpmyadmin?

    Also… after installing easyengine and using it… I love it. Thanks you guys. One problem I have though is that WordPress now asks over and over again for FTP settings in order to do anything for me. I have to change W3TC settings manually (it warns me to make changes), and WordPress themes and plugins will not update without that information.

    I figured this easy-to-install package wouldn’t have that issue. It does likely have to do with the fact that I imported my old database from my other host into this site. How do I fix it?

    1. Also, as an added note… It looks like my RAM is at 100% usage. How can I stop that from happening? I have only 1GB of RAM on the server, and I have the “ideal” cache settings in W3 (using memcache). Am I simply under-powered, or is my settings messed up? It’s the $10 box at Digital Ocean.

    2. You can use HTTP AUTH to protect these pages. If you are using EasyEngine, then these pages must be under `/ee` which is already protected location.

      For all file-transfer purpose, you should use `www-data` user (if following my tutorials). Make sure you chown all files under `/var/www` to `www-data` user/group so your FTP issue might get fixed.

      cd /var/www 
      chown -R www-data: /var/www 

      Then for SFTP…

      passwd www-data

      Set a password for www-data and use that user over SFTP (not normal FTP).

      1. Not for file transfer purposes. I mean, when I visit http://pryormedia.net/opcache.php – I can see it. It’s publicly viewable. I’m sorry to ask this, as I’m sure it’s like Linux 101 stuff… but what can I do to password protect this viewing/page? Restrict it to a username and password. What are the steps I can take? I know they are probably simple, but I don’t know the linux commands to use. Thank you for your time.

  8. I refered to your article before actually having our server used opcache. We now have one, and phpinfo indicates that its up and running, but its not actually caching anything. Aside from the default config, I only edited minimum config variables as suggested in the recommended settings: http://www.php.net/manual/en/opcache.installation.php

    Someone at stackoverflow has the same problem, but noone is answering. The server is mint, PHP has just been upgraded from 5.4 to 5.5.10. Where do you think I should start looking to fix this?

    1. Try using config I posted in above article. Use site for a while. Check opcache stats again from webserver.

      You should see cache usage. If not, there could be some issue with php-build as config part is very small.

      I am not sure how did you install php, but if you are using wordpress and nginx – try http://rtcamp.com/easyengine . PHP it installs definiely have zend opcache cache working.

Comments are closed on this article.
Please use our free support forum for support and discussions.