Php Nginx上游超时

Php Nginx上游超时,php,nginx,Php,Nginx,因此,我最近安装了nginx,现在它给了我一些错误,并关闭了nginx。。2小时?我怎样才能修好它?在错误日志中关闭之前,我收到了相同的错误。我在错误日志中也收到了许多其他错误,如果这与此有关 我在windows 2008服务器上使用了nginx和PHP 2015/04/06 14:07:29 [error] 5812#5480: *552 upstream timed out (10060: A connection attempt failed because the connect

因此,我最近安装了nginx,现在它给了我一些错误,并关闭了nginx。。2小时?我怎样才能修好它?在错误日志中关闭之前,我收到了相同的错误。我在错误日志中也收到了许多其他错误,如果这与此有关

我在windows 2008服务器上使用了nginx和PHP

    2015/04/06 14:07:29 [error] 5812#5480: *552 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 108.162.229.140, server: http://mywebsite.com, request: "GET /assets/ajax/get_bar.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com", referrer: "http://mywebsite.com/play"
2015/04/06 14:07:31 [error] 5812#5480: *600 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 141.101.98.47, server: centralrp.co.uk, request: "GET /assets/ajax/get_bar.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "centralrp.co.uk", referrer: "http://centralrp.co.uk/play"
2015/04/06 14:10:19 [error] 5812#5480: *663 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 141.101.98.47, server: mywebsite.com, request: "GET /home HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com", referrer: "http://mywebsite.com/index"
2015/04/06 14:19:52 [error] 5812#5480: *665 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 141.101.98.100, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com"
2015/04/06 14:21:29 [error] 5812#5480: *667 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 141.101.98.100, server: mywebsite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mywebsite.com", referrer: "http://mywebsite.com/"
上面是错误日志,每次关闭前我都会记录错误,这是我的配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;
root /Dropbox/Website;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            rewrite ^/hk/(.*)$ /index.php?hk=$1;
    rewrite ^/(|/)$ /index.php?url=$1;
    rewrite ^/([a-zA-Z0-9_-]+)(|/)$ /index.php?url=$1;
    rewrite ^/(.*).htm$ /$1.php;
    rewrite ^/business/manage/(.*)/(.*)/?$ /index.php?bm=$2&cid=$1;
    rewrite ^/tickets/manage/(.*)/(.*) /index.php?url=manage_ticket&t=$1 last;
        }

        #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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  C:/Dropbox/Website/$fastcgi_script_name;
    include        fastcgi_params;
    }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
添加到位置

proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
例如

location /cron/ {

...    

proxy_read_timeout 3600s;
proxy_send_timeout 3600s;    

}

我对此类问题的诊断不太熟悉,但您可以在系统上查看一些线索。“上游超时”可能是由于客户端请求太多,或者由于网络/dns/数据库/etc故障,请求处理php代码中的某个地方被阻止,并且默认超时太长,因此fastcgi被阻止,无法处理后续请求。也许您可以先在不使用nginx的情况下单独检查fastcgi或php代码,以验证它是否运行良好。

由于您使用的是fastcgi,您可能实际上需要设置fastcgi\u read\u timeout

以下是链接:


尽管如此,它还是更快地关闭了。
location ~ .php$ {
  fastcgi_read_timeout 600s;
}