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 返回多 ...
随机推荐
- 钉钉消息通知机器人python版
参考官方文档https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq #coding=utf8 import requests import j ...
- u3d人物控制
//https://blog.csdn.net/Htlas/article/details/79188008 //人物移动 http://gad.qq.com/article/detail/28921 ...
- HashMap多线程put后get为null和多线程put的时候可能导致元素丢失
一.多线程put后get为null 源码定位 void transfer(Entry[] newTable) { Entry[] src = table; int newCapacity = newT ...
- linux mount -t -o 用法
挂接命令(mount) 首先,介绍一下挂接(mount)命令的使用方法,mount命令参数非常多,这里主要讲一下今天我们要用到的. 命令格式: mount [-t vfstype] [-o optio ...
- you-get 2017-06-02
可下载优酷土豆的1080p视频 修订版本 针对最近优酷土豆升级后无法下载的问题进行修改 需要安装 python3 和 ffmpeg http://pan.baidu.com/s/1c2hBCe0
- 数字证书及CA的扫盲介绍
★ 先说一个通俗的例子 考虑到证书体系的相关知识比较枯燥.晦涩.俺先拿一个通俗的例子来说事儿. ◇ 普通的介绍信 想必大伙儿都听说过介绍信的例子吧?假设 A 公司的张三先生要到 B 公司去拜访,但是 ...
- fiddler 抓取 安卓模拟器 https包
2017-12-12 16:47:45 星期二 需要材料: 1. fiddler 2. 逍遥模拟器 步骤: 1. fiddler->tool->Optiions...->connec ...
- FreeSWITCH voicemail
功能描述:分机不存在时,进行语音留言. 步骤: 1.编译mod_voicemail 模块.默认是已经有编译 2.加载mod_voicemail模块: fs_cli --> reload mo ...
- 用layui搭建的后台框架
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- python多线程中锁的概念
1 2 3 4 5 6 7 8 mutex = threading.Lock() #锁的使用 #创建锁 mutex = threading.Lock() #锁定 mutex.acquire([time ...