[英]504 gateway timeout nginx+php5-fpm
I realize that this may be a duplicate question, but none other helped me (after for the solution searching for 4 days). 我意识到这可能是一个重复的问题,但是没有其他人帮助我(解决方案搜索4天后)。
I'm using nginx + php5-fpm for a web application. 我正在将nginx + php5-fpm用于Web应用程序。 It worked flawlessly in Apache, so I know it's some configuration problem. 它在Apache中完美运行,所以我知道这是一些配置问题。
My web pages load like they should 1-5 times, and then they just don't load, and then I get a 504 gateway timeout everytime. 我的网页加载时应该是它们的1-5次,然后它们只是不加载,然后每次都会收到504网关超时。
In my slow log, I can see that all PHP operations are successfull, and the last function is also executed. 在我的慢日志中,我可以看到所有PHP操作都已成功完成,并且最后一个函数也已执行。 I do not understand, is this because of php5-fpm? 我不明白,这是因为php5-fpm吗?
Slow log : 慢日志:
[28-Jun-2014 12:45:33] [pool www] pid 21245
script_filename = /home/XXX/public_html/feed.php
[0x00000000014a48f8] usleep() /home/XXX/cache.class.php:864
[0x00000000014a46c8] addLock() /home/XXX/cache.class.php:902
[0x00000000014a44e0] increment() /home/XXX/channel.class.php:124
[0x00000000014a4200] incrementWorkstamp() /home/XXX/channel.class.php:102
[0x00000000014a3f20] getWorkstamp() /home/XXX/channel.class.php:103
[0x00000000014a2908] getWorkstamp() /home/XXX/public_html/feed.php:162
And now I'm getting dump failed in slow log : 现在我在缓慢的日志中转储失败:
[28-Jun-2014 12:52:40] [pool www] pid 29136
script_filename = /home/XXX/public_html/index.php
[0x00007fd7388d7620] session_start() /home/XXX/headers.php:2
[0x00007fd7388d7068] +++ dump failed
nginx configuration for web application: Web应用程序的Nginx配置:
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /home/XXX/public_html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
error_page 500 /errors/6.php;
error_page 404 /errors/4.php;
error_page 403 /errors/2.php;
if (!-e $request_filename){
rewrite ^/user\/([^/]+)\/?([a-zA-Z]*)? /profile.php?username=$1&tab=$2 last;
}
if (!-e $request_filename){
rewrite ^/messages\/([^/]+)\/? /messages.php?chat=$1 last;
}
if (!-e $request_filename){
rewrite ^/interests\/([^/]+)\/? /interests.php?interest=$1 last;
}
if (!-e $request_filename){
rewrite ^/(.*?)/?$ /$1.php last;
}
}
UPDATE : Can session_start() be the culprit? 更新:session_start()是罪魁祸首吗? I think it hangs on start? 我认为它挂起了吗?
Solved. 解决了。 Apparently, it was the function getWorkstamp() causing problems, with an infinite loop. 显然,这是函数getWorkstamp()导致问题的原因,并带有无限循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.