Installation
As of PHP 8.5.0, OPcache is always built into the PHP binary and is always
loaded. The --enable-opcache and
--disable-opcache configure flags have been
removed, and PHP no longer produces opcache.so or
php_opcache.dll files.
Using
Prior to PHP 8.5.0, OPcache could only be compiled as a shared extension.
If you had disabled the building of default extensions with
--disable-all, you had to compile PHP with
the --enable-opcache option for OPcache
to be available. Once compiled, you could use the
zend_extension configuration
directive to load OPcache with
Recommended php.ini settingsThe following settings are generally recommended as providing good performance: opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 ; prior to PHP 7.2.0 opcache.enable_cli=1 You may also want to consider disabling opcache.save_comments and enabling opcache.enable_file_override, however note that you will have to test your code before using these in production as they are known to break some frameworks and applications, particularly in cases where documentation comment annotations are used. On Windows, opcache.file_cache_fallback should be enabled, and opcache.file_cache should be set to an already existing and writable directory. A full list of configuration directives supported by OPcache is also available. |