PHP查询数据库较慢,nginx 超时 返回 504:Sorry, the page you are looking for is currently unavailable.
2017-12-13 18:13
531 查看
现象:
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);
相关文章推荐
- Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
- Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
- Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
- Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
- Nginx--Sorry, the page you are looking for is currently unavailable
- debug note-- nginx php-fpm : Error:The page you are looking for is temporarily unavailable.
- NGINX 运行 PHP正常,运行CGI出现 The page you are looking for is temporarily unavailable 错误
- Nginx报错:Sorry, the page you are looking for is currently unavailable. Please try again later.
- 服务器nginx配置问题the page you are looking for is currently unavailable
- Sorry, the page you are looking for is currently unavailable
- 解决nginx的The page you are looking for is temporarily unavailable错误办法
- nginx+php-fpm运行php "The page you are looking for is temporarily unavailable. Please try again later"
- An error occurred. Sorry, the page you are looking for is currently unavailable. Please try again later.
- 解决nginx的An error occurred. The page you are looking for is temporarily unavailable错误办法
- The page you are looking for is temporarily unavailable.Please try again later.
- Nginx+Tomcat7:The page you are looking for is temporarily unavailable.Please try again later.
- the page you are looking for is temporarily unavailable. Please try again later 解决方案
- Sorry, the page you are looking for could not be found.
- 166 You are managing a 24*7 database. The backup strategy for the database is to perform user-manage
- URAL 1997 Those are not the droids you're looking for(二分图)