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.
- Install the PHP Zend OPcache:
yum install php-pecl-zendopcache
- Configure Zend OPcache optimized for your PHP application. Edit opcache.ini:
vi /etc/php.d/opcache.ini
... and change the following to:
opcache.revalidate_freq=0 opcache.validate_timestamps=0 opcache.max_accelerated_files=20000 opcache.memory_consumption=128 opcache.interned_strings_buffer=16 opcache.fast_shutdown=1
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
- 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
- Restart your Apache:
service httpd restart
- You can download the web UI for Zend OPcache status at https://raw.github.com/rlerdorf/opcache-status/master/opcache.php. Make sure that you protect this web UI from prying eyes.
Comments
You're welcome. Glad Zend…
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.
Thanks for such nice article
Thanks a lots for your such nice article, where easy install process has been given.
Thanks
Thanks!
you mad my day
HI,
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
AWESOME - you dah man!
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.
location of opcache.ini
Hello -
on CentOS 7 with php7 I found the opcache.ini file here:
/etc/php.d/10-opcache.ini
arpeggio
Tue, 05/08/2018 - 13:05
In reply to location of opcache.ini by Kevin Althaus (not verified)
Prefixed with number and hyphen
Hello,
Yes we can see some opcache.ini prefixed with number and hyphen. Thanks.
great !
Thanks a lot !
Finally !!
[email protected]
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.