gpt4 book ai didi

php - 带有 Nginx 1.6.2 和 PHP 5.6.4 的 Ubuntu 14.04 上的 502 Bad Gateway

转载 作者:行者123 更新时间:2023-12-04 19:17:13 24 4
gpt4 key购买 nike

我在需要 的脚本上收到 502 Bad Gateway 响应超过 5 分钟 .

服务器在 Ubuntu 14.04 上运行,带有 Nginx 1.6.2 和 PHP 5.6.4

我创建了一个测试函数,但失败了:

    public function test(){
sleep(600);
}

我试过改变 fastcgi 参数,没有改变。

配置:
server {
listen 80;
server_name www.xxxx.xx;
root /home/forge/xxxx.xx/public;

# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

index index.html index.htm index.php;

charset utf-8;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

access_log off;
error_log /var/log/nginx/xxxx.xx-error.log error;

error_page 404 /index.php;

location ~ \.php$ {
fastcgi_param PHP_VALUE "newrelic.appname=xxxx.xx";
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}

}

nginx.conf http block (我改变的部分):
http {
fastcgi_buffers 32 32k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
# EDIT: Added and tried these:
client_header_timeout 3600;
client_body_timeout 3600;
proxy_read_timeout 3600;
proxy_connect_timeout 3600;

}

php.ini:
max_execution_time = 3600

日志错误:
2015/10/20 10:01:12 [error] 5132#0: *297705 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 195.215.168.170, server: xxxx.xx, request: "GET /cron/test HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xxxx.xx"

花了无数小时寻找解决方案,但我尝试过的每个解决方案都没有任何效果。因此,张开双臂欢迎任何帮助!

最佳答案

通过增加 request_terminate_timeout /etc/php5/fpm/pool.d/www.conf 中的值,我能够摆脱 502 Bad Gateway。

感谢@JuniusRendel 的解决方案。

关于php - 带有 Nginx 1.6.2 和 PHP 5.6.4 的 Ubuntu 14.04 上的 502 Bad Gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33231880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com