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

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


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 ;-)


I had a lot of dead-ends trying to figure this out. After trying BaronVonKaneHoffen's solution, still no beans. I read in the Homebrew documentation after reinstalling:

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

PATH="/usr/local/sbin:$PATH"

The OSX native php-fpm was running, not the one packaged from homebrew.

I edited the $PATH file by writing the .bash_profile script as follows:

In terminal:

cdtouch .bash_profilenano .bash_profile

Then write in the file:

export PATH=/usr/local/sbin:${PATH}

and save.

Restart and see if that helps!


I've solved this problem, the reason is php process have not write permission for session file path, so the solution is:

  1. edit /usr/local/etc/php/5.6/php.ini and give session.save_path a writable directory;
  2. /usr/local/opt/php56/sbin/php56-fpm reload;