【问题标题】:php-fpm + nginx + upload results in 502 Bad Request recv() failed()php-fpm + nginx + 上传导致 502 Bad Request recv() failed()
【发布时间】:2015-04-10 16:26:51
【问题描述】:

在将文件上传到服务器时遇到问题。

我使用以下:

  • Ubuntu 14.04 64 位
  • nginx 1.4.6
  • php5-fpm 5.5.9

应接收文件的应用程序位于 Zend Framework 2.4.0 之上。

每次我想上传文件时,都会收到 502 Bad Request 响应。

nginx的error.log显示:

[error] 21217#0: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream

我阅读了很多关于此错误的信息,但没有任何帮助。

我做到了:

  • 在 php.ini 中禁用 opcache
  • 为 php-fpm 从套接字切换到 tcp
  • 为 php 设置文件大小
  • 为 nginx 和 php-fpm 设置超时

如果有人有想法,如果你能提供一点帮助,那就太好了:)

问候 尼尔森

【问题讨论】:

    标签: nginx ubuntu-14.04 php bad-request


    【解决方案1】:

    尝试打开您的 fastcgi 池配置: vim /etc/php5/fpm/pool.d/www.conf

    改听: 听 = 127.0.0.1:9000

    打开你的 nginx 站点配置: vim /etc/nginx/sites-available/your-site.conf

    将 unix:/var/run/php5-fpm.sock 替换为: 127.0.0.1:9000;

    重启nginx和php5-fpm。

    【讨论】:

    • 为什么?您能否提供使用 tcp/ip 而不是套接字的理由?
    • @foozy 我在很多 ubuntu 14.04 的安装中都看到了这个错误,因为默认情况下,ubuntu 14.04 中的 php 版本配置为通过 tcp 而不是 .sock 运行。在早期版本中,默认值为 .sock
    猜你喜欢
    • 2019-03-07
    • 2019-12-17
    • 2015-05-17
    • 1970-01-01
    • 2014-03-27
    • 2014-10-17
    • 2018-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多