【问题标题】:502 Bad Gateway Nginx Mac OS X Yosemite php56 php-fpm502 Bad Gateway Nginx Mac OS X Yosemite php56 php-fpm
【发布时间】:2015-05-17 09:40:48
【问题描述】:

我是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 配置文件 /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 虚拟服务器配置 /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 配置文件 /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

【问题讨论】:

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


    【解决方案1】:

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

    1. 编辑/usr/local/etc/php/5.6/php.ini并给session.save_path一个可写的目录;
    2. /usr/local/opt/php56/sbin/php56-fpm reload;

    【讨论】:

      【解决方案2】:

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

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

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

      OSX 本机 php-fpm 正在运行,而不是从 homebrew 打包的那个。

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

      在终端:

      cd
      touch .bash_profile
      nano .bash_profile
      

      然后写入文件:

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

      然后保存。

      重启看看有没有帮助!

      【讨论】:

        【解决方案3】:

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

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

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

        您的 FPM 日志中的 SIGSEGV 表示“分段错误”,这是错误中的错误……我认为 PHP 的胆量,而不是配置的东西……当然,更聪明的人可以对此进行扩展 ;-)

        【讨论】:

          猜你喜欢
          • 2019-12-17
          • 2014-03-27
          • 2019-03-07
          • 2014-10-17
          • 2018-09-12
          • 2015-05-25
          • 1970-01-01
          • 2016-04-15
          • 1970-01-01
          相关资源
          最近更新 更多