php 502.88,Nginx+PHP-FPM 访问出现 502错误
游戲后端代碼采用Nginx+PHP-FPM的方式部署。放問游戲的時(shí)候偶爾會(huì)出現(xiàn)502錯(cuò)誤。
Nginx錯(cuò)誤日志出現(xiàn)以下日志
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: ""
現(xiàn)列出排查思路
1.
在/etc/php.ini中設(shè)置PHP腳本執(zhí)行的最長(zhǎng)時(shí)間max_execution_time = 30,這里設(shè)置為30秒。
2.
在/etc/php-fpm.conf 中設(shè)置PHP-FPM進(jìn)程處理每個(gè)進(jìn)程的超時(shí)時(shí)間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 中設(shè)置
fastcgi_connect_timeout 60; 設(shè)置Nginx和FastCGI Server建立連接的超時(shí)時(shí)間,默認(rèn)是60秒,但是這個(gè)值不能經(jīng)常超過75秒
fastcgi_send_timeout 60;? ? 設(shè)置Nginx傳送請(qǐng)求到FastCGI Server的超時(shí)時(shí)間
fastcgi_read_timeout 60;? ? 設(shè)置FastCGI Server讀取請(qǐng)求的超時(shí)時(shí)間
Nginx 的詳細(xì)介紹:請(qǐng)點(diǎn)這里
Nginx 的下載地址:請(qǐng)點(diǎn)這里
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的php 502.88,Nginx+PHP-FPM 访问出现 502错误的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。