2012-10-01 29 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的评论并链接到他们的博客,但我想在这里加入相关信息可能会有帮助。