php 502.88,Nginx+PHP-FPM 访问出现 502错误

游戏后端代码采用Nginx+PHP-FPM的方式部署。放问游戏的时候偶尔会出现502错误。

Nginx错误日志出现以下日志

2014/07/05 17:20:58 [error] 18431#0: *148739 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.1.56, server: , request: "POST /gateway.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: ""

现列出排查思路

1.

在/etc/php.ini中设置PHP脚本执行的最长时间max_execution_time = 30,这里设置为30秒。

2.

在/etc/php-fpm.conf 中设置PHP-FPM进程处理每个进程的超时时间request_terminate_timeout = 30s

3.

在/etc/php-fpm.conf中开启PHP的慢日志

request_slowlog_timeout = 1s

slowlog = /var/log/php-fpm/www-slow.log

4.

在Nginx配置文件nginx.conf 中设置

fastcgi_connect_timeout 60; 设置Nginx和FastCGI Server建立连接的超时时间,默认是60秒,但是这个值不能经常超过75秒

fastcgi_send_timeout 60;    设置Nginx传送请求到FastCGI Server的超时时间

fastcgi_read_timeout 60;    设置FastCGI Server读取请求的超时时间

Nginx 的详细介绍:请点这里

Nginx 的下载地址:请点这里

0b1331709591d260c1c78e86d0c51c18.png


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部