码迷,mamicode.com
首页 > 数据库 > 详细

PHP查询数据库较慢,nginx 超时 返回 504:Sorry, the page you are looking for is currently unavailable.

时间:2017-12-13 23:27:08      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:rom   art   reload   read   class   fastcgi   failed   数据库   bsp   

现象:

PHP查询数据库较慢,大约 60s 后 nginx 返回 504:Sorry, the page you are looking for is currently unavailable.

检查log:

从 /etc/nginx/nginx.conf 找到 /var/log/nginx/access.log 和 /var/log/nginx/error.log

log 显示 upstream timed out (110: Connection timed out) while reading response header from upstream

解决办法:

Nginx upstream timed out (why and how to fix)

添加带有注释的语句

    location ~ \.php$ {
    #    root           html;
        fastcgi_read_timeout 300;  #########https://distinctplace.com/2017/04/22/nginx-upstream-timed-out/       upstream timed out (110: Connection timed out) while reading response header from upstream
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

 

执行 service nginx reload 之后,执行查询,返回页面没有显示 table,继续检查log

"PHP message: PHP Warning: file_get_contents(http://127.0.0.1/xxx): failed to open stream: HTTP request failed! in /home/www/uninum/web.php on line 50

PHP message: PHP Notice:  Trying to get property of non-object in xxx.php on line 54" while reading response header from upstream

同步设置  file_get_contents 超时

php file_get_contents 获取文件超时的处理方法  以及post 和 多次重试

$opts = array(  
    ‘http‘=>array(  
        ‘method‘=>"GET",  
        ‘timeout‘=>300,  
    )  );  
$context = stream_context_create($opts);       
$html =file_get_contents(‘http://www.example.com‘, false, $context); 

 

PHP查询数据库较慢,nginx 超时 返回 504:Sorry, the page you are looking for is currently unavailable.

标签:rom   art   reload   read   class   fastcgi   failed   数据库   bsp   

原文地址:http://www.cnblogs.com/my8100/p/8034291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!