我遇到了長時(shí)間運(yùn)行的 PHP 腳本的問題:<?phpsleep(70); # extend 60sphpinfo();每次 60 秒后都會收到504 Gateway Time-out來自 Nginx 的響應(yīng)而終止。當(dāng)我檢查 Nginx 錯(cuò)誤時(shí),我可以看到請求超時(shí):... [error] 1312#1312: *2023 upstream timed out (110: Connection timed out) while reading response header from upstream, ... , upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock", ...我瀏覽了相關(guān)問題并嘗試增加超時(shí)創(chuàng)建/etc/nginx/conf.d/timeout.conf具有以下內(nèi)容的文件:proxy_connect_timeout 600;proxy_send_timeout 600;proxy_read_timeout 600;send_timeout 600;fastcgi_read_timeout 600;fastcgi_send_timeout 600;fastcgi_connect_timeout 600;我還閱讀了有關(guān)fastcgi和核心模塊的 Nginx 文檔,搜索默認(rèn)設(shè)置為 60 秒的任何配置。我排除了client_*超時(shí),因?yàn)樗鼈兎祷豀TTP 408而不是HTTP 504響應(yīng)。這是我的 FastCGI 的 Nginx 服務(wù)器配置部分:location ~ \.php$ { fastcgi_pass unix:/run/php/php7.0-fpm.sock; include fastcgi_params;}從我目前閱讀的內(nèi)容來看,這似乎不是 PHP 的問題,而 Nginx 應(yīng)該歸咎于超時(shí)。盡管如此,我也嘗試修改 PHP 中的限制:我的價(jià)值觀來自phpinfo():default_socket_timeout=600max_execution_time=300max_input_time=-1memory_limit=512Mphp-fpm 池配置還啟用了以下功能:catch_workers_output = yesrequest_terminate_timeout = 600php-fpm 日志中沒有任何內(nèi)容。我也是使用亞馬遜的負(fù)載均衡器來路由到服務(wù)器,但是超時(shí)配置也從默認(rèn)的 60 秒增加了。我不知道還能去哪里看,在所有更改期間我都重新啟動(dòng)了 php-fpm 和 nginx。
Nginx + Php-fpm fastcgi 上游超時(shí)
繁星點(diǎn)點(diǎn)滴滴
2022-07-22 10:08:42