简体   繁体   English

PHP 5.5 OPCache无法处理apache

[英]PHP 5.5 OPCache not working on apache

I'm in charge of the opcode cache exchange here in my company, we're moving from eaccelerator to the Zend OPCache shipped with PHP 5.5. 我负责我公司的操作码缓存交换,我们正在从eaccelerator转移到PHP 5.5附带的Zend OPCache。

When I access PHP in CLI, it seems like the OPCache is working fine: 当我在CLI中访问PHP时,似乎OPCache工作正常:

PHP 5.5.5 (cli) (built: Oct 15 2013 10:29:13)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

But when I access my website via Apache, the benchmarks show no improvements compared to the same pages using no opcode cache. 但是当我通过Apache访问我的网站时,与没有使用操作码缓存的相同页面相比,基准测试没有显示出任何改进。 Also, get_loaded_extensions(true) returns an empty array. 此外, get_loaded_extensions(true)返回一个空数组。

Can anyone answer me why on earth it isn't working? 任何人都可以回答我为什么它在地球上不起作用?

I'm using windows 7, Apache 2.4.6 from Apache Lounge, PHP 5.5.5 from windows.php.net. 我正在使用Windows 7,来自Apache Lounge的Apache 2.4.6,来自windows.php.net的PHP 5.5.5。


EDIT: 编辑:

As requested, my OPCache configuration: 根据要求,我的OPCache配置:

[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
opcache.revalidate_freq=60
;opcache.revalidate_path=0
;opcache.save_comments=1
;opcache.load_comments=1
opcache.fast_shutdown=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0

Found the answer! 找到答案了!

zend_extension extensions must set the complete path, not a relative one. zend_extension扩展必须设置完整路径,而不是相对路径。

In this case, zend_extension="C:\\Apache24\\php\\ext\\php_opcache.dll" solved my problems. 在这种情况下, zend_extension="C:\\Apache24\\php\\ext\\php_opcache.dll"解决了我的问题。

WINDOWS PHP 7 SOLUTION WINDOWS PHP 7解决方案

By default there are opcache settings in php.ini files like opcache.eneable but enabling opcache does not take effect unless you add: 默认情况下,php.ini文件中有opcache设置,如opcache.eneable,但启用opcache不会生效,除非你添加:

zend_extension=php_opcache.dll

to your config file. 到您的配置文件。 Remember it is zend_extension and not regular exstension ! 记住它是zend_extension而不是常规的exstension!

Make sure that you have "opcache" in your phpinfo(); 确保你的phpinfo()中有“opcache”; report. 报告。 By default : 默认情况下

A DLL for this PECL extension is currently unavailable. 此PECL扩展的DLL当前不可用。 See also the building on Windows section. 另请参见Windows上构建部分。

Can you confirm that the extension is loaded? 你能确认扩展已加载吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM