Dan*_*ter 13 apache-http-server php xdebug macos
我正在运行 Mac OS X 10.9.4,包括内置的 apache2 网络服务器和来自 brew 的 PHP 5.5.14(包:php55、php55-intl、php55-pdo-pgsql、php55-xdebug)。
运行此设置时,它运行良好。但是,一段时间后,我将针对每个请求运行 403 错误。我查看了 apache 错误日志,发现如下内容:
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/Users/daniel/Development/massiveart/sulu-complete/app/bootstrap.php.cache): failed to open stream: Too many open files in /Users/daniel/Development/massiveart/sulu-complete/web/website.php on line 10, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP 1. {main}() /Users/daniel/Development/massiveart/sulu-complete/web/website.php:0, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/Users/daniel/Development/massiveart/sulu-complete/web/../app/bootstrap.php.cache' (include_path='.:/usr/local/Cellar/php55/5.5.14/lib/php') in /Users/daniel/Development/massiveart/sulu-complete/web/website.php on line 10, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://sulu.lo/de
[Fri Jul 25 05:28:18 2014] [error] [client 127.0.0.1] PHP 1. {main}() /Users/daniel/Development/massiveart/sulu-complete/web/website.php:0, referer: http://sulu.lo/de
[Fri Jul 25 05:28:40 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:41 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:41 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:41 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:45 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
[Fri Jul 25 05:28:45 2014] [crit] [client 127.0.0.1] (24)Too many open files: /Users/daniel/Development/massiveart/sulu-complete/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable, referer: http://sulu.lo/de
Run Code Online (Sandbox Code Playgroud)
在我看来,该文件无法再读取,并且以某种方式返回 403。我已经发现了某些限制,但是 launchctl 返回我对打开的文件有一个无限的硬限制:
~ $ launchctl limit
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
memlock unlimited unlimited
maxproc 709 1064
maxfiles 256 unlimited
Run Code Online (Sandbox Code Playgroud)
我也已经尝试使用命令将 maxfiles 设置为 4096 launchctl limit maxfiles 4096 16384
,但一段时间后问题仍然存在。知道我还能检查什么吗?
更新:当lsof -c httpd
按照戈登戴维森的建议运行命令时,我可以看到有很多条目,如下所示:
httpd 1361 _www 15u IPv4 0xb306b48659f63853 0t0 TCP localhost:50603->localhost:cslistener (CLOSED)
Run Code Online (Sandbox Code Playgroud)
我可以说我使用的应用程序正在使用 websockets,并且当 websockets 不可用或对应的应用程序没有在服务器上运行时,它也在使用回退。让我困惑的是 -(CLOSED)
部分,为什么它仍然被列出?
更新:一段时间后,我查找了 cslistener 端口,它实际上是 9000,这又是 xdebug 正在侦听远程调试的端口。所以我想我那里有一些错误的配置,或者它是 xdebug 中的一个错误(我使用的是 XDebug 2.2.5,由 brew 安装)
Ste*_*ber 14
您是否在 Mac 上使用 PHPStorm 和 XDEBUG?
我也有同样的问题。我在这里发现了一个提交给 XDEBUG 的开放错误:
http://bugs.xdebug.org/view.php?id=1070
此错误现已修复:
我刚刚合并了 Sean Dubois 的一个补丁,它应该可以解决这个 \o/! 该补丁将在 2.3.4 和 2.4.0 中发布。
我相信这是提交:https : //github.com/xdebug/xdebug/commit/6efc6588efc277d648a78b69c11c721992c996f9
确保您使用的是带有此补丁的更新版本。
我很确定您在 apache 中运行的某些东西(可能是 PHP 模块,但很难确定)正在泄漏文件描述符。也就是说,它打开文件,然后无限期地打开它们。如果是这种情况,增加打开文件限制只会使达到限制所需的时间更长。您真正需要做的是追踪打开所有文件并让它们保持打开状态的内容。
您可能会对lsof
("LiSt Open Files") 命令有所了解:
sudo lsof -c httpd
Run Code Online (Sandbox Code Playgroud)
当 apache 没有运行很长时间时运行它以查看正常情况,然后在达到限制时再次运行。在第二个输出中查找许多第一个列表中没有的附加文件。请注意,这会有些复杂,因为它会列出所有httpd 进程打开的文件,并且(取决于您的 apache 设置和服务器负载)可能有很多;重要的是单个进程打开的文件数,而不是所有服务器进程的总数。您还可以使用一次sudo lsof -p someprocessID
只列出一个服务器进程。
希望看到额外打开的文件是什么会让您很好地了解是什么打开了它们并使它们保持打开状态。
归档时间: |
|
查看次数: |
8728 次 |
最近记录: |