How to install PHP Opcache on MacOS High Sierra?

I use standard Apache and PHP 7.1 (not Homebrew) that comes with Mac High Sierra. Nevertheless, this version does not seem to support Opcache, although it should be standard with PHP 7. It is even listed in phpinfo()the section "Module Authors", but none of them shows its actual installation. The call opcache_get_statusgives a fatal error.

I installed the extension through Homebrew and linked the file opcache.so. It seems to be working on the CLI, but not on Apache. For some reason, the CLI and web use different ini files:

  • /usr/local/etc/php/7.1/php.ini for CLI
  • /etc/php.ini for the internet

The CLI parses addition files, including /usr/local/etc/php/7.1/conf.d/ext-opcache.ini, and php -idisplays Opcache. But phpinfo()there is no browser - no additional ini files are processed.

I currently have this in /etc/php.ini:

[opcache]
zend_extension="/usr/local/opt/php71-opcache/opcache.so"
opcache.enable=1

But still nothing. I followed the same process for xdebug and it worked fine. What am I missing?


I wonder if it will be easier to use the PHP version for homebrew. But I do not have the required file .so. Various tutorials say you need to put this in Apache httpd.conf:

LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so

But the directory libexecdoes not exist. Exists lib, but neither directory has a file .so.

+4
source share
1 answer

For me, this worked with the following steps:

  • Searching extension_dirthe page "phpinfo ()", I have a path /usr/lib/php/extensions/no-debug-non-zts-20160303
  • ls -lh /usr/lib/php/extensions/no-debug-non-zts-20160303, "opcache.so", , "High Sierra"
  • "/etc/php.ini" ( "/etc/php.ini.default" ) :
[opcache]
zend_extension = opcache.so
opcache.enable = 1
  1. apache, "opcache"

/

Mac OS High Sierra "opcache" , opcahe Mac OS High Sierra:

  • "/etc/php.ini", , : sudo cp /etc/php.ini.default /etc/php.ini
  • zend_extension = opcache.so /etc/php.ini "opcache" :

opcache php.ini :

[opcache]
zend_extension = opcache.so
opcache.enable = 1
+6

Source: https://habr.com/ru/post/1690651/


All Articles