Apache FCGI PHP-FPM Mac OS X 10.8无法绑定

所以我发现了一些关于这类问题的其他线索,但是他们的解决scheme并不适合我。

基本上,这是我的开发机器,安装已经好几个星期了,但突然间,我得到了很多与这些错误的问题:

[Thu Sep 27 16:28:43 2012] [error] [client 127.0.0.1] FastCGI: comm with server "/Library/WebServer/Documents/php5.external" aborted: idle timeout (60 sec) [Thu Sep 27 16:28:43 2012] [error] [client 127.0.0.1] FastCGI: incomplete headers (0 bytes) received from server "/Library/WebServer/Documents/php5.external" 

我没有改变任何有关服务器configuration。 显然有些事情已经改变了,或者我变得不幸了。

安装如下:

 Apache/2.2.22 (Unix) DAV/2 mod_fastcgi/2.4.6 mod_ssl/2.2.22 OpenSSL/0.9.8r $ php-fpm -v PHP 5.3.15 (fpm-fcgi) (built: Aug 19 2012 09:06:12) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans $ sudo lsof -i TCP:9000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME php-fpm 97167 _www 6u IPv4 0xd65451f140772337 0t0 TCP localhost:cslistener (LISTEN) php-fpm 97174 _www 0u IPv4 0xd65451f140772337 0t0 TCP localhost:cslistener (LISTEN) php-fpm 97174 _www 3u IPv4 0xd65451f14739c337 0t0 TCP localhost:cslistener->localhost:54750 (CLOSE_WAIT) $ tail -16 /etc/apache2/httpd.conf <IfModule mod_fastcgi.c> FastCGIExternalServer /Library/WebServer/Documents/php5.external -flush -host 127.0.0.1:9000 -idle-timeout 60 AddHandler php5-fcgi .php Action php5-fcgi /usr/lib/cgi-bin/php5.external Alias /usr/lib/cgi-bin/ /Library/WebServer/Documents/ <Directory /usr/local/sbin> Options ExecCGI FollowSymLinks SetHandler fastcgi-script Order allow,deny Allow from all AllowOverride All </Directory> </IfModule> 

这几乎是默认的php-fpm.conf,日志位置发生变化,ondemand进程pipe理器,pm.max_children = 1,其他都是默认值。

我尝试了几十次重新启动Apache,并以不同的顺序杀死了所有的php-fpm进程。

任何build议都将被大力鼓励,欢迎,赞赏,尝试和希望。

更新28/09/2012

好的,所以我使用了本教程,并尝试使用套接字方法来查看它是否是TCP端口冲突 – 事实certificate它不是。 使用套接字也没有帮助像这样的每10秒的错误信息:

对于TCP:

 [28-Sep-2012 08:44:58] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48) [28-Sep-2012 08:44:58] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48) [28-Sep-2012 08:44:58] ERROR: FPM initialization failed [28-Sep-2012 08:44:58] ERROR: FPM initialization failed 

对于套接字:

 [28-Sep-2012 08:48:32] ERROR: An another FPM instance seems to already listen on /tmp/php5-fpm.sock [28-Sep-2012 08:48:32] ERROR: An another FPM instance seems to already listen on /tmp/php5-fpm.sock [28-Sep-2012 08:48:32] ERROR: FPM initialization failed [28-Sep-2012 08:48:32] ERROR: FPM initialization failed 

我弄清楚了如何解决这个问题,而且在我刚刚链接的教程中。 启动代理plistconfiguration需要指定RunOnlyOnce。 不知道这对TCP是否安全。

我确实有一些进展,这可能会使这个问题太具体..我使用NetBeans进行开发,当我试图启动一个debugging会话使用xdebug,它加载好 – 很酷 – 但只要代码需要暂停一个断点,我回到方块1. comm with server ... aborted: idle timeout

为了覆盖我所有的基础,我把httpd.conf中的-idle-timeout设置为300.没有骰子。 如果我closuresNetbeans并且不尝试(永远)开始一个debugging会话,服务器不会死,它会像预期的那样工作。

我即将尝试重新启动我的MacBook,但老实说,这不应该是一个有效的解决scheme..

所以,我觉得我更好地评论这个看到没有其他人。

我不知道如何阻止PHP-FPM在通过TCP侦听时反复logging绑定错误。

我通过切换到unix套接字侦听来解决我的问题,并configuration启动代理在启动时只运行一次PHP-FPM。

我能做的最好。 也许这会帮助别人,idk。

php-fpm.conf

 listen = /tmp/php5-fpm.sock 

httpd.conf

 <IfModule mod_fastcgi.c> AddHandler php5-fcgi .php Action php5-fcgi /php5-fcgi Alias /php5-fcgi /Library/WebServer/CGI-Executables/php-fcgi FastCGIExternalServer /Library/WebServer/CGI-Executables/php-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization -idle-timeout 300 <Directory /usr/local/sbin> Options ExecCGI FollowSymLinks SetHandler fastcgi-script Order allow,deny Allow from all AllowOverride All </Directory> </IfModule> 

/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>homebrew-php.josegonzalez.php53</string> <key>LaunchOnlyOnce</key> <true/> <key>ProgramArguments</key> <array> <string>/usr/local/Cellar/php53/5.3.15/sbin/php-fpm</string> <string>--fpm-config</string> <string>/usr/local/etc/php/5.3/php-fpm.conf</string> </array> <key>RunAtLoad</key> <true/> <key>Username</key> <string>www</string> <key>WorkingDirectory</key> <string>/usr/local/var</string> <key>StandardErrorPath</key> <string>/usr/local/Cellar/php53/5.3.15/var/log/php-fpm.log</string> </dict> </plist>