Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I have found a few other threads about this kind of issue, but their solutions aren't working for me.

Basically, this is my development machine and the setup has been fine for a number of weeks now, but suddenly I'm getting a lot of issues with these errors:

[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"

I haven't changed anything related to the server config. Obviously something must've changed, or I've just become unlucky..

Setup is as follows:

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>

It's pretty much a default php-fpm.conf with the log location changed, ondemand process manager, pm.max_children = 1 and everything else is default.

I've tried restarting apache dozens of times, and killing all the php-fpm processes, in different orders.

Any suggestions will be wildly encouraged, welcomed, appreciated, tried and hoped for.

UPDATE 28/09/2012

Okay, so I used this tutorial and tried the socket approach to see if it was a TCP port collision - turns out its not. Using sockets also didn't help the every-10-second error messages like these:

For 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

For sockets:

[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

I did figure out how to solve this though, and it's in the tutorial I just linked. The launch agent plist configuration needs to specify RunOnlyOnce. Not sure if this is safe for TCP though.

I do have some progress though, which might make this question too specific.. I use NetBeans for development, and when I tried to fire up a debug session using xdebug, it loads fine - cool - but as soon as the code needs pause on a breakpoint, I'm back at square 1. comm with server ... aborted: idle timeout

Just to cover all my bases, I set -idle-timeout in httpd.conf to 300. No dice. If I shutdown Netbeans and don't try (ever) starting a debug session, the server won't die, it'll behave as intended.

I'm about to try rebooting my MacBook, but honestly that shouldn't be a valid solution..

share|improve this question

1 Answer 1

up vote 2 down vote accepted

So, I figured I better comment back on this seeing as nobody else has.

I have NO idea how to stop PHP-FPM from logging the binding errors over and over again when listening via TCP.

I solved my problem by switching to unix socket listening, and configuring the launch agent to run PHP-FPM only once on startup.

Best I could do. Maybe this will help someone, idk.

In php-fpm.conf

listen = /tmp/php5-fpm.sock

In 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>

In /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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.