502 Bad Gateway Nginx Mac OS X Yosemite php56 php-fpm

Mao8a picture Mao8a · Mar 15, 2015 · Viewed 7.9k times · Source

I was Brew’ing PHP, MySQL & Nginx on Mac OS X, but I can't make this work.

Any idea what I'm doing wrong?

phpinfo is working

/log/nginx/access.log

127.0.0.1 - - [14/Mar/2015:21:21:16 -0500] "GET /wp/wp-admin/install.php HTTP/1.1" 502 574 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2331.4 Safari/537.36"

/log/virtualhost/error.log

2015/03/14 21:21:16 [error] 82682#0: *59 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /wp/wp-admin/install.php HTTP/1.1", upstream: "fastcgi://unix:/usr/local/var/run/php-fpm/php-fpm.sock:", host: "localhost"

/log/php-fpm.log

[14-Mar-2015 21:21:16] WARNING: [pool www] child 6851 exited on signal 11 (SIGSEGV) after 11147.271614 seconds from start
[14-Mar-2015 21:21:16] NOTICE: [pool www] child 82712 started

My Nginx conf /usr/local/etc/nginx/nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    include sites-enabled/*.conf;
}

My Nginx virtual server conf /usr/local/etc/nginx/sites-available/local.conf

server {
  listen                *:80;
  server_name           localhost;
  error_log            /log/virtualhost/error.log;
  root                 /server;
  location / {
    try_files  $uri  $uri/  /index.php?$args;
    index index.php;
  }
  location ~ \.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    unix:/usr/local/var/run/php-fpm/php-fpm.sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
  }
}

My php-fpm conf /usr/local/etc/php/5.6/php-fpm.conf

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
;user = _www
;group = _www
listen = /usr/local/var/run/php-fpm/php-fpm.sock

Answer

BaronVonKaneHoffen picture BaronVonKaneHoffen · Mar 30, 2015

I had this problem and solved it by recompiling php with different options:

brew uninstall php56 && brew install php56 --with-debug --without-apache

Seems to be something that went wrong with the original build, maybe those flags or maybe with the tool chain. I seem to remember it complained about not having xcode cli tools the first time round, then installing them and running the build again. Either way, that worked for me.

SIGSEGV in your FPM log means "segmentation fault", which is something wrong in the err.... guts of PHP I think, not a config thing... Sure someone more intelligent can expand on that ;-)