OPcache can only be compiled as a shared extension. If you have disabled the building of default extensions with --disable-all, you must compile PHP with the --enable-opcache option for OPcache to be available.

Once compiled, you can use the zend_extension configuration directive to load the OPcache extension into PHP. This can be done with zend_extension=/full/path/to/ on non-Windows platforms, and zend_extension=C:\path\to\php_opcache.dll on Windows.


If you want to use OPcache with » Xdebug, you must load OPcache before Xdebug.

Recommended php.ini settings

The following settings are generally recommended as providing good performance:


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.

add a note add a note

User Contributed Notes 2 notes

6 years ago
While the "suggested" opcache settings for php.ini might be appropriate for a production server, you're going to want to change several while you're developing, or you're not going to see any changes to your code. Get familiar with what they mean before blindly pasting that into php.ini and assuming things are going to work well.
ijf8090 at gmail dot com
7 months ago
find the location of your php.ini file by typing
php -i | grep php.ini

Restart your web server to activate your changes
in my case
sudo /usr/sbin/apachectl restart
To Top