php - 504 网关超时媒体殿

标签 php timeout mediatemple http-status-code-504

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

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

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

sleep 将在 60 秒以下的任何值上工作,但超过 60 秒会导致 504 网关错误

我的 phpinfo();输出

max_execution_time 600
max_input_time 180

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

有人可以帮忙吗?谢谢。

**更新**

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

我在我的服务器设置中找不到任何值。 client_header_timeout client_body_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

最佳答案

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

找到您的 nginx.conf 文件(通常位于 /usr/local/nginx/nginx.conf 或有时位于 /etc/nginx/sites-available/default) ,使用 nano 或任何其他文本编辑器打开它,并在 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 的评论和他们博客的链接,但我认为在此处添加相关信息可能会有所帮助。

关于php - 504 网关超时媒体殿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12672340/

相关文章:

php - 从包含 CSS 的 PHP/HTML 文件生成 PDF

php - 如何使用 span 设置 PHP 回显输出的样式

javascript - 如何让 NodeJs 函数等待?

python - 将超时设置为 Tornado 中的 http 请求

nginx - 如何为 nginx 中的所有服务器设置默认指令? (Plesk 的问题)

linux - MediaTemple DV 服务器上的 APC 安装错误

SSL 和 .htaccess 强制 https

php - SSL 错误 SSL3_GET_SERVER_CERTIFICATE :certificate verify failed

php - Zend Framework - 在oop原理中,方法 '$this->getRequest()->getPost()'如何工作?

data-structures - 允许高效优先级更新的优先级队列?