2012-10-01 123 views
8

當我的php腳本需要運行超過60秒時,我總是收到504網關錯誤。504網關超時媒體寺廟

我在專用服務器上的媒體寺廟。我已經聯繫媒體寺廟,他們一直很有幫助,但他們的建議似乎沒有爲我工作我被告知編輯這個文件。

/etc/httpd/conf.d/fcgid.conf

,我有以下

LoadModule fcgid_module modules/mod_fcgid.so 

<IfModule mod_fcgid.c> 

<IfModule !mod_fastcgi.c> 
    AddHandler fcgid-script fcg fcgi fpl 
</IfModule> 

    FcgidIPCDir /var/run/mod_fcgid/sock 
    FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm 
    FcgidIdleTimeout 300 
    FcgidMaxRequestLen 1073741824 
    FcgidProcessLifeTime 10000 
    FcgidMaxProcesses 64 
    FcgidMaxProcessesPerClass 15 
    FcgidMinProcessesPerClass 0 
    FcgidConnectTimeout 600 
    FcgidIOTimeout 600 
    FcgidInitialEnv RAILS_ENV production 
    FcgidIdleScanInterval 600 

</IfModule> 

,所以我試圖最大一切,盡我所能,來測試這個我只需運行下面的功能。

function test504(){ 
     @set_time_limit(0); 
     sleep(60); 
     echo "true"; 
    } 

睡眠將工作在60秒以下的任何值返回true,但在60我得到504網關錯誤。

my phpinfo();輸出

max_execution_time 600 
max_input_time 180 

我看到的增加該fastcgi_connect_timeout幾個職位,但不知道在哪裏可以找到這種媒體的寺廟。

誰能幫助感謝

UPDATE仍然無法修復這個

與支持,我被告知我需要編輯nginx.conf聊天后?並被引導到這個職位http://blog.secaserver.com/2011/10/nginx-gateway-time-out/

無法罰款我的託管上的任何值。 client_header_timeout client_body_timeout send_timeout fastcgi_read_timeout

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

#error_log /var/log/nginx/error.log info; 

#pid  /var/run/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 /var/log/nginx/access.log main; 

    sendfile  on; 
    #tcp_nopush  on; 
    #keepalive_timeout 0; 
    keepalive_timeout 120; 
    #tcp_nodelay  on; 

    #gzip on; 
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)"; 

    server_tokens off; 

    include /etc/nginx/conf.d/*.conf; 
} 

這是推動我瘋了什麼建議???

更新我設法得到這個排序結束後很多頭痛添加博客文章,我如何解決這裏。 http://devsforrest.com/116/boost-settings-on-media-temple-for-maximum-settings

希望這可以幫助別人

+1

我認爲這是一個新的設置,因爲我從來沒有遇到與他們的舊服務器有問題,但有一個新的服務器,我打開並跑到這。你的文章確實幫了很大忙。我的應用程序運行在Apache模塊模式下,這仍然解決了這個問題。真的有幫助! – David

+1

嘿@ user1503606 - 您最後一次更新的作品!發佈它作爲你的答案,並找到解決方案的功勞。 – squarecandy

+0

我建議你重構你的應用程序,以消除需要運行一個腳本超過200毫秒。您可能需要將一些沉重的邏輯移動到背景。使用以下任何技術來幫助您:AJAX,消息隊列,memcache,標誌文件。 –

回答

3

我也有同樣的問題,我通過編輯nginx.conf文件解決了這個問題。在大多數情況下,這可以通過在nginx.conf中添加/增加send_timeout指令來解決。

找到你nginx.conf文件(通常位於/usr/local/nginx/nginx.conf或有時/etc/nginx/sites-available/default),使用納米或任何其他文本編輯器打開它,並添加HTTP {之間以下行}所以它看起來像:

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 /var/log/nginx/access.log main; 

sendfile  on; 
#tcp_nopush  on; 
#keepalive_timeout 0; 
keepalive_timeout 120; 
#tcp_nodelay  on; 

#gzip on; 
#gzip_disable "MSIE [1-6]\.(?!.*SV1)"; 

server_tokens off; 

send_timeout 10m; 

include /etc/nginx/conf.d/*.conf; 
} 

就我而言,我不得不增加一些其他指令,如:

client_header_timeout 10m; 
client_body_timeout 10m; 
send_timeout 10m; 
fastcgi_read_timeout 10m; 

了。

一旦你編輯的文件,只需用nginx的重裝:

kill -HUP `ps -ef | grep nginx | grep master | awk {'print $2'}` 

sudo service nginx restart 

這應該修復它。

(我發現這裏的指令:http://blog.secaserver.com/2011/10/nginx-gateway-time-out/

PS:我看到了OP的評論並鏈接到他們的博客,但我想在這裏加入相關信息可能會有幫助。