504 Gateway Time-out 錯誤處理記錄
阿新 • • 發佈:2019-07-14
20190713 新建了一個 phpmyadmin,在 import 一個 install.sql 執行的時候,發現nginx 配置的phpmyadmin 網站一個超時錯誤 :
504 Gateway Time-out
碰巧伺服器上既有apache,也有nginx,之前本地 apache 網站是不出現這個錯誤的!於是同樣配置了一個 apache 的 phpmyadmin,測試發現不出現超時錯誤!
所以,問題還在 nginx 網站配置
1、 網上搜了一些文章,我主要參考了以下 2 個
http://www.scalescale.com/tips/nginx/504-gateway-time-out-using-nginx/
他們講解了一些原理性的東西,最終也沒有附上自己的 nginx 版本和實際操作記錄
伺服器上沒有拿準具體修改哪裡,是不敢貿然動手的! nginx 版本在變化,有些配置檔案內容甚至檔名都不一樣
比方說:我修改了 phh.ini 的 fastcgi_connect_timeout 到 300 之後,在重啟 nginx 服務的時候,就出現了以下錯誤
Failed to start A high performance web server and a reverse pro ~
只好改回去,想好了再動手!
2、以下是我的操作過程記錄
-
檢視版本號和配置位置 $ nginx -v nginx version: nginx/1.10.3 (Ubuntu)
$ whereis php php: /usr/bin/php /usr/bin/php7.0
-
修改 nginx 網站配置 $ vim phpmyadmin.conf 在 php 處理部分加上以下 3 個引數
location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.2-fpm.sock; # by wzh 20190713 for 504 Gateway Time-out # /etc/php/7.2/fpm/php.ini also change fastcgi_connect_timeout 200; fastcgi_send_timeout 200; fastcgi_read_timeout 200; }
-
修改 php.ini $ cd /etc/php/7.2/fpm $ sudo vim php.ini 找到以上 3 個引數值,對應修改以下
;by wzh 20190713 30 --> 200 ,same to max_execution_time max_execution_time = 200 ; by wzh 20190713 60-->200 default_socket_timeout = 200 ;by wzh 20190713 30 --> 200 ,same to max_execution_time max_execution_time = 200
****** 實際過程中,php.ini 是先修改的,這裡為了寫作方便對照,把這 2 個次序反過來了***
- 重新測試,不再出現 504 錯