504 Gateway Time-out 错误处理记录

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/
https://www.jb51.cc/nginx/69483.html

他们讲解了一些原理性的东西,最终也没有附上自己的 nginx 版本和实际操作记录

服务器上没有拿准具体修改哪里,是不敢贸然动手的!
nginx 版本在变化,有些配置文件内容甚至文件名都不一样

比方说:我修改了 phh.ini 的 fastcgi_connect_timeout 到 300 之后,在重启 nginx 服务的时候,就出现了以下错误

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

只好改回去,想好了再动手!

2、以下是我的操作过程记录

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

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

  2. 修改 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;
     }
    
  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 错误!
发布了69 篇原创文章 · 获赞 10 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/u010953609/article/details/95856446