Search code examples
phpmacos-sierraphp-7php-iniopcache

Cannot enable OPcache on MacOS Sierra with PHP 7


I am finding it tricky to enable OPcache on my MacOS Sierra (10.12.6) system.

php --ini shows the ini file used:

Configuration File (php.ini) Path: /usr/local/etc/php/7.0
Loaded Configuration File:         /usr/local/etc/php/7.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.0/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.0/conf.d/ext-pdo_pgsql.ini

My php.ini looks like this:

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

However, when I look at phpinfo() it shows the following: enter image description here enter image description here

I've restarted Apache after making the change to my php.ini to include opcache, but it doesn't appear to be recognised.

I installed PHP with Homebrew, not MAMP although I do have MAMP install but unused.


Solution

  • I got to the bottom of this eventually...

    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.