php 我的 OpCache 正在运行吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22773041/
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
is my OpCache running?
提问by Salvador Dali
I am trying to enable opCache on my server (ubuntu 12.04 LTS
, running apache 2.4.7
with PHP Version 5.5.10-1+deb.sury.org~precise+1
).
我正在尝试在我的服务器上启用 opCache ( ubuntu 12.04 LTS
, running apache 2.4.7
with PHP Version 5.5.10-1+deb.sury.org~precise+1
)。
Before starting to do anything, I read this highly relevant postwhich told me that opCache is disabled by default and I have to manually enable it.
在开始做任何事情之前,我阅读了这篇高度相关的帖子,它告诉我 opCache 默认是禁用的,我必须手动启用它。
I went into php.ini and found that there is no text with opcache.so
, also everything related to opcache is commented out. Like this:
我进入 php.ini 发现没有带 的文本opcache.so
,所有与 opcache 相关的内容都被注释掉了。像这样:
[opcache]
; Determines if Zend OPCache is enabled
;opcache.enable=0
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
This is ok, because the person told that it is disabled. But when I consult phpinfo();
it shows me the following (and based on my understanding it tells me that opCache is already used).
这没关系,因为该人告诉它已禁用。但是当我咨询phpinfo();
它时,它向我展示了以下内容(并且根据我的理解,它告诉我已经使用了 opCache)。
So is my opcache enabled and used and how can I see/verify it?
那么我的 opcache 是否已启用和使用,我如何查看/验证它?
回答by Ray
Have faith in your phpinfo()
, you've got the necessary shared module running or it wouldn't be showing up.
相信你的phpinfo()
,你已经运行了必要的共享模块,否则它不会出现。
Also, your opcache is indeed enabled, but only for web, not cli. The default for the library is enabled for web so , to disableuncomment the line starting with a semicolon like this:
此外,您的 opcache 确实已启用,但仅适用于 Web,不适用于 cli。该库的默认值是为 web so 启用的,以禁用取消注释以分号开头的行,如下所示:
opcache.enable=0
As noted, for command line php use, the default is disabled, to enable it, uncomment and set to 1
如前所述,对于命令行 php 使用,默认是禁用的,要启用它,取消注释并设置为 1
opcache.enable_cli=1
Here is a list of all runtime arguments and there default value for further reference: http://www.php.net/manual/en/opcache.configuration.php
以下是所有运行时参数的列表以及供进一步参考的默认值:http: //www.php.net/manual/en/opcache.configuration.php
If you want a cool web monitor page for it (like apc.php does for apc) try this: https://github.com/rlerdorf/opcache-status
如果你想要一个很酷的网络监控页面(就像 apc.php 对 apc 所做的那样)试试这个:https: //github.com/rlerdorf/opcache-status