XDebug를 사용하여 PHP에서 아파치를 얼마 동안 실행 한 후 Mac OSX에서“너무 많은 파일이 열려 있습니다” 25 05:28:18 2014] [error]

brew의 PHP 5.5.14가 내장 된 apache2 웹 서버를 포함하여 Mac OS X 10.9.4를 실행 중입니다 (패키지 : php55, php55-intl, php55-pdo-pgsql, php55-xdebug).

이 설정을 실행할 때 꽤 잘 작동합니다. 그러나 얼마 후 모든 요청에 ​​대해 403 오류가 발생합니다. 아파치 오류 로그를 찾아서 다음과 같은 것을 발견했습니다.

[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

파일을 더 이상 읽을 수없는 것처럼 보이며 어떻게 든 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

또한 이미 명령을 사용하여 maxfiles를 4096으로 설정하려고 시도했지만 launchctl limit maxfiles 4096 16384시간이 지난 후에도 문제가 계속 발생합니다. 내가 확인할 수있는 다른 아이디어가 있습니까?

업데이트 : lsof -c httpdGordon Davisson이 제안한대로 명령을 실행할 때 다음과 같은 항목이 많이 있음을 알 수 있습니다.

httpd   1361 _www   15u    IPv4 0xb306b48659f63853       0t0     TCP localhost:50603->localhost:cslistener (CLOSED)

내가 사용하는 응용 프로그램은 웹 소켓을 사용하고 있으며 웹 소켓을 사용할 수 없거나 상대방이 서버에서 실행되고 있지 않을 때 대체를 사용하고 있다고 말할 수 있습니다. 내가 혼동하는 (CLOSED)부분 은 무엇입니까 ? 왜 여전히 나열되어 있습니까?

업데이트 : 얼마 후 cslistener 포트를 찾았습니다. 실제로 9000이며 xdebug가 원격 디버깅을 수신하는 포트입니다. 그래서 거기에 잘못된 구성이 있거나 xdebug의 버그 인 것 같습니다 (brew로 설치 한 XDebug 2.2.5를 사용하고 있습니다)



답변

Mac에서 XDEBUG와 함께 PHPStorm을 사용하고 있습니까?

나는 같은 문제를 가지고있다. 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

이 패치로 업데이트 된 버전사용하고 있는지 확인하십시오 .


답변

파일 설명자가 유출되는 아파치 (아마 PHP 모듈이지만 확실하지는 않습니다)에서 무언가를 실행하고 있다고 확신합니다. 즉, 파일을 연 다음 무기한으로 열어 둡니다. 이 경우 열린 파일 제한을 늘리면 제한에 도달하는 데 시간이 더 걸립니다. 실제로해야 할 일은 모든 파일을 열고 열어 두는 것을 추적하는 것입니다.

lsof( “LiSt Open Files”) 명령으로 어떤 일이 일어나고 있는지 알 수 있습니다 .

sudo lsof -c httpd

아파치가 오랫동안 실행되지 않았을 때 실행하여 정상 상태를 확인한 다음 한계에 도달하면 다시 실행하십시오. 두 번째 출력에서 ​​첫 번째 목록에없는 추가 파일이 많이 있는지 확인하십시오. 이것은 모든 httpd 프로세스에 의해 열린 파일을 나열 하고 (아파치 설정 및 서버로드에 따라) 많은 파일이있을 수 있기 때문에 다소 복잡 합니다. 중요한 것은 모든 서버 프로세스에서 전체가 아닌 단일 프로세스로 열린 파일 수입니다. sudo lsof -p someprocessID한 번에 하나의 서버 프로세스 만 나열 하는 데 사용할 수도 있습니다 .

추가로 열린 파일이 무엇인지 알면 파일을 열고 열어 두는 것이 좋습니다.


답변

xdebug.ini에 다음 줄을 추가하면 문제가 해결되었습니다.

xdebug.remote_autostart = 0


답변

Brew에서 OSX 10.9.4와 Apache 2.2와 PHP 5.3을 모두 동일하게 사용하고 있습니다.

이것이 실제로 문제를 해결하는 것은 아니지만 Apache MaxRequestsPerChild 설정을 10과 같이 설정하여 포함시킬 수 있습니다. 개발에 적합합니다.

diff -r 2c0473b696fd -r acf809f04b17 apache2/2.2/httpd.conf
--- a/apache2/2.2/httpd.conf    Thu Aug 14 16:14:25 2014 -0500
+++ b/apache2/2.2/httpd.conf    Thu Aug 14 16:19:10 2014 -0500
@@ -437,7 +437,7 @@
 # necessary.

 # Server-pool management (MPM specific)
-#Include /usr/local/etc/apache2/2.2/extra/httpd-mpm.conf
+Include /usr/local/etc/apache2/2.2/extra/httpd-mpm.conf

 # Multi-language error messages
 #Include /usr/local/etc/apache2/2.2/extra/httpd-multilang-errordoc.conf
diff -r 2c0473b696fd -r acf809f04b17 apache2/2.2/extra/httpd-mpm.conf
--- a/apache2/2.2/extra/httpd-mpm.conf  Thu Aug 14 16:14:25 2014 -0500
+++ b/apache2/2.2/extra/httpd-mpm.conf  Thu Aug 14 16:19:10 2014 -0500
@@ -38,7 +38,7 @@
     MinSpareServers       5
     MaxSpareServers      10
     MaxClients          150
-    MaxRequestsPerChild   0
+    MaxRequestsPerChild  10
 </IfModule>

 # worker MPM

누출 된 파일을 제거하기 위해 적어도 자주 아파치를 다시 시작하지 않아도됩니다.


답변