0

在我开发的软件中,用户可以发送 PHP 用来向数据库插入行的 XLS 文件。通常一个文件有 1500 行,在数据库中会产生 7000 行。该过程通常需要 5 到 7 分钟才能完成。

一段时间后,我收到 504 网关超时错误。我做了一项研究,发现解决方案是增加最大执行时间。我试过了,没有,就像配置被忽略了。

max_execution_time = 600
max_input_time = 600

然后我尝试直接在 PHP 上设置它,使用函数ignore_user_abortset_time_limit. 再次,它没有工作。

set_time_limit(0);         //never time out
ignore_user_abort(true);   //ignore abort

在此之后我放弃了,并决定制作一个自定义错误页面来解释错误发生的原因,然后重定向回控制面板。所以,我去了我的 .htaccess 有以下内容:

# Turn on the RewriteEngine
RewriteEngine On
Options +FollowSymLinks +Includes
Options -Indexes
IndexIgnore */*
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|images|robots\.txt)

RewriteRule . index.php?/$0 [L]

并添加了以下语句:

ErrorDocument 504 http://domain/erros/timeout/

当错误再次发生时,它不会重定向到 URL,而是显示默认错误页面。

更新

我使用dreamhost 共享主机。

4

1 回答 1

0

根据文档,这应该不是问题http://wiki.dreamhost.com/Creating_custom_error_pages

我认为您需要使用本地路径,例如

ErrorDocument 504 /cgi-bin/error.php?code=504
于 2014-01-15T16:13:22.110 回答