Enabling Opcache does not work

I am trying to enable Opcache, but for some reason after editing the php.ini file and restarting Apache (even restarting the server) it still won't activate. Running the test I see that the location of the php files is:

Loaded Configuration File   /etc/php5/apache2/php.ini

      

In this file, I added:

zend_extension=/usr/lib/php5/20121212/opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

      

The zend extension was located by locating opcache.so. It didn't work. Then I noticed that php is loading an additional file / etc / php 5 / apache2 / conf.d / 05-opcache.ini. In this file it looks like this:

; configuration for php ZendOpcache module
; priority=05
zend_extension=opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

      

However, after restarting apache, it still won't be enabled. My phpinfo () output displays the following:

Opcode Caching  Disabled

      

How can I enable it?

+4


source to share


5 answers


In the output, phpinfo()

review the files .ini

listed below:

Additional .ini files parsed

Maybe something like



/usr/local/php5/php.d/20-extension-opcache.ini

Make sure this file is set opcache.enable=1

.

+1


source


check the [opcache] section in php.ini



[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=0

      

0


source


Do this first

sudo apt-get install libpcre3-dev

      

then

sudo pecl install zendopcache-beta

      

0


source


You may be looking for ini location

cat /etc/php.d/10-opcache.ini

      

0


source


If all else fails, try:

sudo yum install php-opcache

      

Solved the problem with my version of PHP 7.2 for Fedora.

It turns out that I did not have opcache installed (the main thing was that I was missing the .ini file in the "Analysis of additional .ini files" section in phpinfo ()).

0


source







All Articles