504网关超时媒体圣殿 [英] 504 Gateway Time-out media temple

查看:41
本文介绍了504网关超时媒体圣殿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的 php 脚本需要运行超过 60 秒时,我不断收到 504 网关错误.

I am constantly getting 504 Gateway Errors when my php script needs to run for longer than 60 seconds.

我在专用服务器上的 Media Temple.我已经联系了 Media Temple,他们很有帮助,但他们的建议似乎都不适合我.我被告知要编辑这个文件.

I am on Media Temple on a dedicated server. I have contacted Media Temple and they have been helpful but none of their suggestions seem to work for me. I was told to edit this file.

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

/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>

我已经尝试尽可能地最大化一切.为了测试这个,我只是运行下面的函数.

I have tried to max everything as much as I can. To test this I am just running the function below.

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

Sleep 可以在 60 秒以下的任何值上工作,但任何更多都会导致 504 网关错误

Sleep will work on any value below 60 seconds, but anything more results in a 504 Gateway Error

我的 phpinfo();输出

my phpinfo(); outputs

max_execution_time 600
max_input_time 180

我看过一些关于增加 fastcgi_connect_timeout 设置的帖子,但不知道在 Media Temple 上哪里可以找到.

I have seen a few posts on increasing the fastcgi_connect_timeout setting, but have no idea where to find this on Media Temple.

有人可以帮忙吗?谢谢.

Can anyone help? Thanks.

** 更新 **

与支持人员交谈后,我被告知我需要编辑 nginx.conf 并被定向到这篇文章 http://blog.secaserver.com/2011/10/nginx-gateway-time-out/

After chatting with support I have been told I need to edit nginx.conf and was directed to this post http://blog.secaserver.com/2011/10/nginx-gateway-time-out/

我在我的服务器设置中找不到任何值.client_header_timeoutclient_body_timeout发送超时fastcgi_read_timeout

I can't find any of the values in my server settings. client_header_timeout client_body_timeout send_timeout fastcgi_read_timeout

我的 nginx.conf 文件看起来像这样

my nginx.conf file looks like this

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

** 更新 **

我设法解决了这个问题,并添加了一篇关于我如何修复它的博客文章.

I managed to get this sorted out and added a blog post on how I fixed it.

http://devsforrest.com/116/boost-settings-on-media-temple-for-maximum-settings

推荐答案

我也遇到了同样的问题,我通过编辑 nginx.conf 文件解决了它.在大多数情况下,这可以通过在 nginx.conf 中添加/增加 send_timeout 指令来解决.

I too had the same issue and I solved it by editing nginx.conf file. In most cases, this can be fixed by adding / increasing the send_timeout directive in nginx.conf.

找到您的 nginx.conf 文件(通常位于 /usr/local/nginx/nginx.conf 或有时位于 /etc/nginx/sites-available/default),使用 nano 或任何其他文本编辑器打开它,并在 http { } 之间添加以下几行,使其看起来像:

Find your nginx.conf file (usually located at /usr/local/nginx/nginx.conf or sometimes /etc/nginx/sites-available/default), open it using nano or any other text editor, and add the following lines between the http { } so it looks like:

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

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

In my case, I had to increase some other directives like:

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

也是.

编辑完文件后,只需使用以下命令重新加载 nginx:

Once you've edited the file, just reload nginx with:

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/ )

(I found the directives here: http://blog.secaserver.com/2011/10/nginx-gateway-time-out/ )

PS:我看到了 OP 的评论以及指向他们博客的链接,但我认为在此处添加相关信息可能会有所帮助.

PS: I saw the comment by the OP with a link to their blog but I thought adding the relevant information here might help.

这篇关于504网关超时媒体圣殿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆