Check PHP OPcache usage

I wondered how my enabled OPcache was used. An easy way to check is to use rlerdorf’s OPcache Status page.

The installation is straight forward. Simply download opcache.php from GitHub and install it on the PHP enabled Web Server. Then, you’ll get something like:

You’ll be able to see if the cache is well used and if you need to allocate more memory. If so, on OpenBSD, you can configure something like:

# cat /etc/php-5.6/opcache.ini
zend_extension=opcache.so
opcache.memory_consumption=512
opcache.max_accelerated_files=50000

If using Apache HTTP Server, the script access can be protected using the Location and Require keywords:

Alias "/opcache-status.php" "/home/scripts/opcache-status.php"
<Location "/opcache-status.php">
  Require all denied
  <RequireAny>
    Require ip 127
    Require ip 10.0.0
  </RequireAny>
</Location>

And that’s all!

No Comments

Leave a Reply

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

*

%d bloggers like this: