PHP查询数据库较慢,nginx 超时 返回 504:Sorry, the page you are looking for is currently unavailable.
现象:
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.的更多相关文章
- Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
查看了进程, nginx, php-fpm都在运行, 排除程序错误, 那么就是配置的问题了. 一个可能的错误, 是由于配置中的 fastcgi_pass 配置错了 错误的配置如下 server { l ...
- 浏览器给openresty连接发送参数请求,查询数据库,并返回json数据
nginx.conf配置文件 #user nobody; worker_processes 1; error_log logs/error.log; #error_log logs/error.log ...
- python查询数据库返回数据
python查询数据库返回数据主要运用到flask框架,pymysql 和 json‘插件’ #!/usr/bin/python # -*- coding: UTF-8 -*- import pymy ...
- 【问题记录】MyBatis查询数据库返回多个不同类型参数的结果集的接收方式
其实是个非常简单的问题,但是这玩意儿弄得我很难受,又浪费了一个下午的时间,简直了…… 问题大概是,我在查询数据库时,查询的结果有两个,一个是varchar格式的字段,一个int格式字段,例如: sel ...
- shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出
shell脚本中sqlite3命令查询数据库失败返回空,并将错误信息打印到标准错误输出 如: #/bin/sh local ret='sqlite3 test.db "select test ...
- mybatis学习----------查询数据库返回结果为空
用mybits查询数据库时,如果参数已传入sql,sql也已经执行了,但是返回结果为空,首先保证数据库中有对应数据,如果有对应数据仍返回null,是数据库配置文件有问题.解决方案如下:1.mapper ...
- python3.6 + selenium2.53.1 查询数据库并将返回的内容中每一行的内容转换成class对象
环境: win10 python3.6 selenium2.53.1 准备工作:先安装pymysql python2.x链接数据库使用MySQLdb,而python3.x链接数据库使用pymysql ...
- laravel 查询数据库first()返回的数据转数组
使用 get_object_vars()可以将他抓转为数组get_object_vars — 返回由对象属性组成的关联数组: 在laravel中其实还可以用 toArray(); json_decod ...
- Django 1.8.11 查询数据库返回JSON格式数据
Django 1.8.11 查询数据库返回JSON格式数据 和前端交互全部使用JSON,如何将数据库查询结果转换成JSON格式 环境 Win10 Python2.7 Django 1.8.11 返回多 ...
随机推荐
- window.opener和window.open的使用
window.opener和window.open的使用 window.opener是指调用window.open方法的窗口.window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击 ...
- Codeforces 675D Tree Construction Splay伸展树
链接:https://codeforces.com/problemset/problem/675/D 题意: 给一个二叉搜索树,一开始为空,不断插入数字,每次插入之后,询问他的父亲节点的权值 题解: ...
- python操作三大主流数据库(11)redis的安装和简单使用
命令参考文档:http://www.redis.cn/topics/introduction.html 1.安装及配置官网https://redis.io中文网站:http://www.redis.c ...
- zepplin0.7.2报错ERROR, exception: null, result: %text java.lang.NullPointerException的处理
zepplin0.7.2报错ERROR, exception: null, result: %text java.lang.NullPointerException的处理 问题描述: 使用zeppli ...
- php的ts和nts安装包
2017-12-29 15:17:05 星期五 翻译一下PHP对 ts , nts 的解释 官网说明地址: http://windows.php.net/download (windows下载页左 ...
- const成员函数和mutable关键字
一.const成员函数 class MyClass { public: void fun() const { } private: int m_nValue; } const成员函数内不能修改成员变量 ...
- 粘包-socketserver实现并发
- 深入Golang之sync.Pool详解
我们通常用golang来构建高并发场景下的应用,但是由于golang内建的GC机制会影响应用的性能,为了减少GC,golang提供了对象重用的机制,也就是sync.Pool对象池. sync.Pool ...
- winform数据存储的方式
存储的方式有三种: 一.SQL数据库 二.Access(office 2007版本以上是需要安装驱动的) 三.XML
- Confluence 6 升级自定义的站点和空间应用你的自定义布局
当你升级你的 Confluence 到其他一个主要的 Confluence 发行版本的时候,你需要手动应用你修改过的任何全局或者空间级别的布局.除非有特殊的声明,针对一些非主要的 Confluence ...