11

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

I_G
  • 413
  • 1
  • 4
  • 18

2 Answers2

10

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.

Aioros
  • 4,373
  • 1
  • 18
  • 21
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1) Are you sure you are editing the correct php.ini file, there are 2? 2) Are you using the web phpinfo() or the PHP CLI phpinfo()? And what exectly does not work mean? – RiggsFolly Sep 22 '15 at 12:26
  • No there is only one php.ini I dont have 2. I dont know what's the difference for the phpinfo() or PHP CLI phpinfo() but im working in local. And the opcache doesnt work. I still the exclamation mark near the opcache. – I_G Sep 22 '15 at 12:30
  • The output from `phpinfo()` you gave seems to say opcache is working! – RiggsFolly Sep 22 '15 at 12:32
  • But why I still have that warning. And how I know it's working? Is it possible to do a test or something like that? – I_G Sep 22 '15 at 12:33
  • I am fairly sure the red Exclamation mark is just because this extension is loaded using `zend_extension=` rather than the normal `extension=` – RiggsFolly Sep 22 '15 at 12:34
  • 1
    Yes I just checked, The Excalmation mark is irrelevant – RiggsFolly Sep 22 '15 at 12:48
  • Well I dont have it now. I dont know why, I dont know how but it seems to work :) – I_G Sep 22 '15 at 12:55
  • I have also found opcache.enable=0 present in php configurations, too. That needs to be set to 1 (or the line just commented out), – Weston Wedding Oct 18 '16 at 04:19
  • @WestonWedding Correct, but as the question states that `opcache.enable=1` along with other opcache configuration settings I didn't see these as relevant to this answer – RiggsFolly Oct 18 '16 at 08:01
  • would development with opcache be ok if you turned on timestamp validation? http://php.net/manual/en/opcache.configuration.php#ini.opcache.validate-timestamps – PathToLife Dec 05 '18 at 03:20
  • 1
    @Pathfinder Development with opcache is fine, as long as you know that occasional hiccups are possible and how to flushing the cache when needed – RiggsFolly Dec 05 '18 at 12:26
0

Since you are working on windows i think you should set the path like this

zend_extension=C:\path\to\php_opcache.dll (win) [Note the slash]

for your case: zend_extension=C:\wamp\bin\php\php5.5.12\ext\php_opcache.dll

Note that when the path contains spaces you should wrap it in quotes:

zend_extension="C:\Program Files\PHP5.5\ext\php_opcache.dll"

Try it out and see if it helps

MadHatter
  • 11
  • 1
  • https://www.devside.net/wamp-server/enabling-wampdevelopers-php-opcache-opcode-cache did u follow all these steps? [Step 3 especially] – MadHatter Sep 21 '15 at 15:04
  • in my phpinfo() it says up and running so how I know if its really running? – I_G Sep 22 '15 at 06:34
  • Windows backslashes are most likely to be seen as escape characters in a quoted literal. Its normal to use unix forward slashes in these type of statements even on windows. And WAMPServer does not and should not get installed in `program files`. – RiggsFolly Sep 22 '15 at 10:41