如何在 Windows 上安装 Zend OPcache Extension + PHP >= 5.4
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24155516/
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
How to install Zend OPcache Extension + PHP >= 5.4 on Windows
提问by Flasz
Is it possible to install Zend OPcache module for PHP 5.4.29 in Windows Environment? I have downloaded OPCache that was meant to be compatible with PHP 5.4 but
是否可以在 Windows 环境中为 PHP 5.4.29 安装 Zend OPcache 模块?我已经下载了与 PHP 5.4 兼容的 OPCache,但是
php -v
does not show anything new loaded.
不显示任何新加载的东西。
回答by edigu
Zend OPcache extension is compatible with 5.3.* 5.4.* and PHP 5.5.*
Zend OPcache 扩展兼容 5.3.* 5.4.* 和 PHP 5.5.*
You should download the source-codeof the extension and compile yourself or try to download pre-compiled windows version hereand call the extension in your php.ini like this:
您应该下载扩展的源代码并自行编译或尝试在此处下载预编译的 Windows 版本并在您的 php.ini 中调用扩展,如下所示:
zend_extension=/path/to/opcache.dll
Notice:
注意:
- There are multiple versions exists for windows binaries: Thread Safe and Non-Thread Safe. You should pick the correct one according your needs. Learn more about TS and NTS here.
- Each build has a php version in filename. In your case, you should use
php_opcache-7.X.X-5.4-XX-XX-XXX.zip
.
- Windows 二进制文件有多个版本:线程安全和非线程安全。您应该根据自己的需要选择正确的。在此处了解有关 TS 和 NTS 的更多信息。
- 每个构建在文件名中都有一个 php 版本。在您的情况下,您应该使用
php_opcache-7.X.X-5.4-XX-XX-XXX.zip
.
UpdateSince opcache is a part of php core for a long time and this question is highly visible on search engines, I wanted to update my answer.
更新由于 opcache 长期以来一直是 php 核心的一部分,并且这个问题在搜索引擎上非常明显,我想更新我的答案。
According to documentation, enabling opcache using following lines in php.ini:
根据文档,使用 php.ini 中的以下几行启用 opcache:
zend_extension=php_opcache.dll
opcache.enable=On
opcache.enable_cli=On
then restarting the web server (IIS I guess) should be enough.
然后重新启动 Web 服务器(我猜是 IIS)应该就足够了。
回答by Jacob Stamm
In addition to @edigu's answer, here are some additional considerations for Windows Server 2012R2/IIS 8+ users. PHP version is 7.2. I'm using the old Codeplex version of PHP Manager, so perhaps these steps don't apply if you're using the recently revamped version.
除了@edigu 的回答,这里还有一些针对 Windows Server 2012R2/IIS 8+ 用户的额外注意事项。PHP 版本是 7.2。我使用的是旧的 Codeplex 版本的 PHP 管理器,所以如果您使用的是最近改进的版本,这些步骤可能不适用。
- Enabling
php_opcache.dll
in the extensions GUI doesn't work. In php.ini, find the line that saysextension=php_opcache.dll
rename it tozend_extension=php_opcache.dll
. - Find every line that begins with
opcache.
and make sure it isn't commented out. - In addition to the
On
andOff
values for toggling properties, such as inopcache.enable=On
, you can also use1
and0
respectively.
php_opcache.dll
在扩展 GUI 中启用不起作用。在 php.ini 中,找到将其extension=php_opcache.dll
重命名为zend_extension=php_opcache.dll
.- 找到以 开头的每一行,
opcache.
并确保它没有被注释掉。 - 除了用于切换属性的
On
和Off
值(例如 in )之外opcache.enable=On
,您还可以分别使用1
和0
。
Restart the site in IIS, then the Zend OPcache section on the phpinfo() screen should report everything up and running.
在 IIS 中重新启动站点,然后 phpinfo() 屏幕上的 Zend OPcache 部分应该报告一切正常运行。