2013-05-29 56 views
0

我很新使用nginx,我遇到了一個問題,在請求從我的計算機本地運行nginx的500頁後,我開始得到504網關超時錯誤。nginx在500次請求後給出504錯誤

我的nginx.conf文件看起來像這樣

events { 
    worker_connections 1024; 
} 


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

    sendfile  on; 

    keepalive_timeout 65; 

    proxy_buffer_size 128k; 
    proxy_buffers 4 256k; 
    proxy_busy_buffers_size 256k; 

    server { 
     listen  80; 
     server_name localhost; 

     charset utf-8; 

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

     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root html; 
     } 

     location ~ \.php$ { 
     try_files $uri =404; 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      root   html; 
      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_read_timeout 5s; 
      include  fastcgi_params; 
     } 
    } 

    server { 
    listen   80; 
    server_name  local-testserver; 
    error_log  logs/local-testserver.error.log; 
    access_log  logs/local-testserver.access.log; 
    keepalive_timeout 1s; 

    location/{ 
     root  C:/Code/PHP/TestServer; 
     index  index.php; 
    } 



     location ~ \.php$ { 
      root   C:/Code/PHP/TestServer; 
      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_index index.php; 
     } 

    } 
} 

而且在index.php的TESTSERVER /只包含

<?php 
    echo "hi"; 
?> 

我在AS3 URLRequest類測試這一點,但實際上我嘗試手動發送500個請求,看看是否有所作爲,並且在這兩種情況下,501st請求都有504錯誤。重新啓動服務器允許我再發出500個請求。

關於可能發生什麼或如何解決它的任何想法?

回答

0

原來,這不是一個nginx問題,而是一個FastCGI問題。在啓動FastCGI之前將PHP_FCGI_MAX_REQUESTS = 0設置爲環境變量應允許任意數量的請求。