Enable opcache for php in wamp

I_G picture I_G · Sep 21, 2015 · Viewed 21.7k times · Source

I try to enable opcache on wamp but it doesnt work. I changed the settings like this :

[opcache]
zend_extension=C:/wamp/bin/php/php5.5.12/ext/php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000

I always have the red exclamation mark in the extension of php for opcache whats wrong? some help pls

And it is in the the phpinfo()

Zend OPcache
Opcode Caching  Up and Running
Optimization    Enabled
Startup OK
Shared memory model win32
Cache hits  0
Cache misses    1
Used memory 483608
Free memory 133734120
Wasted memory   0
Cached scripts  1
Cached keys 2
Max keys    7963
OOM restarts    0 
Hash keys restarts  0
Manual restarts 0


opcache.blacklist_filename  no value    no value
opcache.consistency_checks  0   0
opcache.dups_fix    Off Off
opcache.enable  On  On
opcache.enable_cli  Off Off
opcache.enable_file_override    Off Off
opcache.error_log   no value    no value
opcache.fast_shutdown   1   1
opcache.file_update_protection  2   2
opcache.force_restart_timeout   180 180
opcache.inherited_hack  On  On
opcache.interned_strings_buffer 8   8
opcache.load_comments   1   1
opcache.log_verbosity_level 1   1
opcache.max_accelerated_files   4000    4000
opcache.max_file_size   0   0
 opcache.max_wasted_percentage  5   5
opcache.memory_consumption  128 128
opcache.mmap_base   no value    no value
opcache.optimization_level  0xFFFFFFFF  0xFFFFFFFF
opcache.preferred_memory_model  no value    no value
opcache.protect_memory  0   0
opcache.restrict_api    no value    no value
opcache.revalidate_freq 60  60
opcache.revalidate_path Off Off
opcache.save_comments   1   1
opcache.use_cwd On  On
opcache.validate_timestamps On  On

I found this If you want to know if it works : https://github.com/rlerdorf/opcache-status/blob/master/opcache.php

Answer

RiggsFolly picture RiggsFolly · Sep 22, 2015

In PHP5.5.12 opcache is delivered as a zend extension but it is found in the standard ext folder.

You would therefore load it just like any other PHP extension, apart from using the zend_extension rather than extension paramter, so edit your php.ini file using the wampmanager menus to make sure you edit the right file like so :-

wampmanager -> PHP -> php.ini

First check that this parameter is set correctly :

extension_dir = "C:/wamp/bin/php/php5.5.12/ext/"

Now where you have loaded the OpCache dll in your example, do it like this and it will be loaded from the default extension folder just like a normal extension= would be :-

zend_extension=php_opcache.dll

You could do it like this :-

zend_extension="C:/wamp/bin/php/php5.5.12/ext/php_opcache.dll"

but there is no need to specify the full path as it is loaded from the standard ext folder.

Warning

If you are still developing you almost definitely don't what this turned on as it won't add any benefit and could add time to a standard compilation, recaching after every code change, and possibly not re-compiling and using the cached code when you don't want it to.