504 Gateway Time-out 錯誤處理記錄

20190713 新建了一個 phpmyadmin,在 import 一個 install.sql 執行的時候,發現nginx 配置的phpmyadmin 網站一個超時錯誤 :

504 Gateway Time-outphp

碰巧服務器上既有apache,也有nginx,以前本地 apache 網站是不出現這個錯誤的!因而一樣配置了一個 apache 的 phpmyadmin,測試發現不出現超時錯誤!

因此,問題還在 nginx 網站配置

一、 網上搜了一些文章,我主要參考瞭如下 2 個

http://www.scalescale.com/tips/nginx/504-gateway-time-out-using-nginx/ https://www.jb51.cc/nginx/69483.htmlhtml

他們講解了一些原理性的東西,最終也沒有附上本身的 nginx 版本和實際操做記錄nginx

服務器上沒有拿準具體修改哪裏,是不敢貿然動手的! nginx 版本在變化,有些配置文件內容甚至文件名都不同web

比方說:我修改了 phh.ini 的 fastcgi_connect_timeout 到 300 以後,在重啓 nginx 服務的時候,就出現瞭如下錯誤sql

Failed to start A high performance web server and a reverse pro ~apache

只好改回去,想好了再動手!vim

二、如下是個人操做過程記錄

  1. 查看版本號和配置位置 $ nginx -v nginx version: nginx/1.10.3 (Ubuntu)服務器

    $ whereis php php: /usr/bin/php /usr/bin/php7.0php7

  2. 修改 nginx 網站配置 $ vim phpmyadmin.conf 在 php 處理部分加上如下 3 個參數socket

    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;
     }
  3. 修改 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 個次序反過來了***

  1. 從新測試,再也不出現 504 錯誤!
相關文章
相關標籤/搜索