在 wamp 中为 php 启用 opcache
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32697619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable opcache for php in wamp
提问by I_G
I try to enable opcache on wamp but it doesnt work. I changed the settings like this :
我尝试在 wamp 上启用 opcache,但它不起作用。我改变了这样的设置:
[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
php for opcache 的扩展名里总是有红色感叹号是怎么回事?一些帮助请
And it is in the the phpinfo()
它在 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
我发现了这个如果你想知道它是否有效:https: //github.com/rlerdorf/opcache-status/blob/master/opcache.php
采纳答案by RiggsFolly
In PHP5.5.12 opcache is delivered as a zend extension but it is found in the standard ext
folder.
在 PHP5.5.12 中 opcache 是作为 Zend 扩展提供的,但它位于标准ext
文件夹中。
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 :-
因此,除了使用zend_extension
而不是extension
参数之外,您可以像任何其他 PHP 扩展一样加载它,因此请php.ini
使用 wampmanager 菜单编辑您的文件,以确保您像这样编辑正确的文件:-
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 :-
现在你已经在你的例子中加载了 OpCache dll,这样做,它会从默认扩展文件夹中加载,就像正常情况一样extension=
:-
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.
但无需指定完整路径,因为它是从标准ext
文件夹加载的。
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.
如果您仍在开发中,您几乎肯定不会打开它,因为它不会增加任何好处,并且可能会增加标准编译的时间,在每次代码更改后重新缓存,并且可能不会重新编译和使用缓存的代码你不希望它。
回答by MadHatter
Since you are working on windows i think you should set the path like this
由于您在 Windows 上工作,我认为您应该像这样设置路径
zend_extension=C:\path\to\php_opcache.dll (win) [Note the slash]
zend_extension=C:\path\to\php_opcache.dll (win) [注意斜线]
for your case: zend_extension=C:\wamp\bin\php\php5.5.12\ext\php_opcache.dll
对于您的情况: 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"
zend_extension="C:\Program Files\PHP5.5\ext\php_opcache.dll"
Try it out and see if it helps
试试看是否有帮助