I am trying to enable Opcache, but for some reason, after editing my php.ini file and restarting apache (even rebooting the server), it still does not get enabled. Running a test I can see that that the php files location:
Loaded Configuration File /etc/php5/apache2/php.ini
Within that file I have 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 location of the zend extension was defined by locate opcache.so. This did not work. I then noticed that php was loading an additional file /etc/php5/apache2/conf.d/05-opcache.ini. In that file it looks like:
; 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 will not enable. The following is in my phpinfo() output:
Opcode Caching Disabled
How can I get it to enable?
In the output from phpinfo()
, have a look at the .ini
files listed under:
Additional .ini files parsed
There may be something like
/usr/local/php5/php.d/20-extension-opcache.ini
Make sure opcache.enable=1
is set in this file.
If everything else fails, you could try:
sudo yum install php-opcache
Solved the issue on my PHP 7.2 version for Fedora.
Turns out I didn't have opcache installed (a key giveaway was the lack of a .ini file on the "Additional .ini files parsed" section of phpinfo()).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With