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

时间:2015-03-15 04:02:40

标签: mysql nginx osx-yosemite php php-5.6

我是Brew’ing PHP, MySQL & Nginx on Mac OS X,但我无法完成这项工作。

知道我做错了吗?

phpinfo正在运作

/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

我的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;
}

我的Nginx虚拟服务器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;
  }
}

我的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

3 个答案:

答案 0 :(得分:4)

我遇到了这个问题并通过使用不同选项重新编译php来解决它:

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

似乎原始构建出了问题,可能是那些标志或者可能是工具链。我似乎记得它抱怨第一次没有xcode cli工具,然后安装它们并再次运行构建。无论哪种方式,这对我有用。

你的FPM日志中的SIGSEGV意味着"分段错误",这是错误的错误....我认为PHP的内容,而不是配置的东西......当然有人更聪明可以扩展那;;)

答案 1 :(得分:2)

我有很多死角试图解决这个问题。在尝试了BaronVonKaneHoffen的解决方案之后,仍然没有豆子。我在重新安装后阅读了Homebrew文档:

  

OS X 10.8及更新版预装了php-fpm,以确保您使用的是brew版本,以确保/ usr / local / sbin位于PATH中的/ usr / sbin之前:

     

PATH =#&34;在/ usr / local / sbin中:$ PATH"

OSX原生php-fpm正在运行,而不是homebrew打包的。{/ p>

我通过编写.bash_profile脚本来编辑$ PATH文件,如下所示:

在终端:

cd
touch .bash_profile
nano .bash_profile

然后写入文件:

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

并保存。

重新启动并查看是否有帮助!

答案 2 :(得分:1)

我已经解决了这个问题,原因是php进程没有写入会话文件路径的权限,所以解决方法是:

  1. 编辑 /usr/local/etc/php/5.6/php.ini 并为 session.save_path 提供可写目录;
  2. / usr / local / opt / php56 / sbin / php56-fpm reload ;