现象:

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.的更多相关文章

  1. Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.

    查看了进程, nginx, php-fpm都在运行, 排除程序错误, 那么就是配置的问题了. 一个可能的错误, 是由于配置中的 fastcgi_pass 配置错了 错误的配置如下 server { l ...

  2. 浏览器给openresty连接发送参数请求,查询数据库,并返回json数据

    nginx.conf配置文件 #user nobody; worker_processes 1; error_log logs/error.log; #error_log logs/error.log ...

  3. python查询数据库返回数据

    python查询数据库返回数据主要运用到flask框架,pymysql 和 json‘插件’ #!/usr/bin/python # -*- coding: UTF-8 -*- import pymy ...

  4. 【问题记录】MyBatis查询数据库返回多个不同类型参数的结果集的接收方式

    其实是个非常简单的问题,但是这玩意儿弄得我很难受,又浪费了一个下午的时间,简直了…… 问题大概是,我在查询数据库时,查询的结果有两个,一个是varchar格式的字段,一个int格式字段,例如: sel ...

  5. shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出

    shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出 如: #/bin/sh local ret='sqlite3 test.db "select test ...

  6. mybatis学习----------查询数据库返回结果为空

    用mybits查询数据库时,如果参数已传入sql,sql也已经执行了,但是返回结果为空,首先保证数据库中有对应数据,如果有对应数据仍返回null,是数据库配置文件有问题.解决方案如下:1.mapper ...

  7. python3.6 + selenium2.53.1 查询数据库并将返回的内容中每一行的内容转换成class对象

    环境: win10 python3.6 selenium2.53.1 准备工作:先安装pymysql python2.x链接数据库使用MySQLdb,而python3.x链接数据库使用pymysql ...

  8. laravel 查询数据库first()返回的数据转数组

    使用 get_object_vars()可以将他抓转为数组get_object_vars — 返回由对象属性组成的关联数组: 在laravel中其实还可以用 toArray(); json_decod ...

  9. Django 1.8.11 查询数据库返回JSON格式数据

    Django 1.8.11 查询数据库返回JSON格式数据 和前端交互全部使用JSON,如何将数据库查询结果转换成JSON格式 环境 Win10 Python2.7 Django 1.8.11 返回多 ...

随机推荐

  1. Unity中的GC以及优化

    [简介] 常见的 Unity GC 知识点总结出来的思维导图 Unity 官方文档,正巧在博客园发现了已经有位大神(zblade)把原文翻译出来了,而且质量很高~,译文地址 在这里.下面我就可耻地把译 ...

  2. 微信小程序-输入框输入文字后,将光标移到文字中间,接着输入文字后光标又自动跳到最后

    问题描述: input输入框输入一段文字后,将光标移到文字中间,接着输入文字后光标又自动跳到最后去了. 原因: input事件中,给input框绑定任何事件后,在处理事件时 setData之后就会让光 ...

  3. Java:自动设置环境变量(转载)

    引用: https://blog.csdn.net/qq_22498277/article/details/72149038 脚本下载地址:http://files.cnblogs.com/floww ...

  4. cmder 神器 +curl

    cmder 神器 https://www.jianshu.com/p/7a706c0a3411 curl https://www.cnblogs.com/zhuzhenwei918/p/6781314 ...

  5. python----动态规划

    不能放弃治疗,每天都要进步!! 什么时候使用动态规划呢? 1. 求一个问题的最优解 2. 大问题可以分解为子问题,子问题还有重叠的更小的子问题 3. 整体问题最优解取决于子问题的最优解(状态转移方程) ...

  6. IOS UINavigationController 更改返回按钮

    UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom]; back.titleLabel.font = [UIFont boldSy ...

  7. ios  调整 label 的字体行间距

     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 200) ...

  8. 软件测试作业 - fault error failure

    给出的题目如下: 我的解答如下: For program 1:1. where i > 0 is the fault , it should be changed to i>= 0 to ...

  9. Hibrenate之事务的理解以及代码编写

    3 事务概念 事务(Transaction)是并发控制的单位,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位.通过事务,SQL Server能将逻辑相关的一组操作绑定 ...

  10. Confluence 6 Home 和其他重要的目录

    Confluence 安装目录 Confluence 安装的目录(Confluence Installation directory)定义的是 Confluence 是在那里进行安装的.这个目录有时候 ...