Setup Zend OPcache on CentOS 7

Zend OPcache speeds up the execution of PHP codes. How? We know that PHP is an interpreted language where the instructions are written in a script and needs a process to parse/interpret and execute it. Zend OPcache removes the parse/interpret part by compiling the script to directly executed it by the target machine which makes the execution of your PHP application more faster. This article will show how to setup Zend OPcache on CentOS 7.

The following procedures are tested on my Linode server running Centos 7 64-bit Linux distribution.

  1. Install the PHP Zend OPcache:
    yum install php-pecl-zendopcache
  2. Configure Zend OPcache optimized for your PHP application. Edit opcache.ini:
    vi /etc/php.d/opcache.ini

    ... and change the following to:


    Comment out the line "opcache.validate_timestamps=0" in your development environment.

    To get the "opcache.max_accelerated_files" you may use this:

    find . -type f -print | grep php | wc -l

    Since I'm using Dupal, I added these:

    find . -type f -print | grep module | wc -l
    find . -type f -print | grep inc | wc -l
  3. If you don't want to apply Zend OPcache to your development site you may add its path at opcache-default.blacklist:
    vi /etc/php.d/opcache-default.blacklist
  4. Restart your Apache:
    service httpd restart
  5. You can download the web UI for Zend OPcache status at Make sure that you protect this web UI from prying eyes.


A big thank you for this tutorial.
I installed Zend OpCache and it speeded my websites to a significant level. However, since I am not that experienced in these kind of things, I thought that installing the Zend framework will help as well, but that process ruined my websites and they weren't loading. So I had to revert the changes and now everything is fine.

You're welcome. Glad Zend OpCache helped speed up your websites.

You will install Zend framework if your PHP applications are developed using it. In my case, I use Drupal CMS and it does not use Zend framework. There is no reason for me to install Zend framework.


after installing nextcloud, i get the error that opcache is not configured.
I try different things as long, to i read your post.
create the /etc/php.d/opcache.ini
and it works.
thanks a lot for sharing.

PS sorry for my bad english

Thank you so much for this article!! Almost perfect (I had to create the opcache.ini file, had to change directory to run commands, etc.)... yeah, I'm a novice but you made this much easier than the other 435 websites I visited ---> and your instructions actually gave me results!! THANK YOU.

Hello -

on CentOS 7 with php7 I found the opcache.ini file here:

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.