简体   繁体   English

如何使用.htaccess在Apache-FastCGI-PHP应用程序上扩展请求/连接超时

[英]How to Extend the Request/Connection Timeout on Apache-FastCGI-PHP application using .htaccess

I am trying to extend the Connection/Request Timeout at our allotted server space. 我试图在我们分配的服务器空间扩展连接/请求超时。

The Reason i am trying to do this is, for some operations in my application takes more than 120 seconds, then the server is not waiting for the operation to complete. 我试图这样做的原因是,对于我的应用程序中的某些操作需要超过120秒,然后服务器不等待操作完成。 It returns 500 Internal Server Error , exactly after 120 seconds. 它会在120秒后返回500内部服务器错误

To test it i placed the below script on server: 为了测试它,我将以下脚本放在服务器上:

<?php
sleep(119);
echo "TEST";
?>

It will return TEST, to the browser after 119 seconds. 它将在119秒后返回TEST,返回浏览器。

But when i place below script: 但是当我放在脚本下面时:

<?php
sleep(121);
echo "TEST";
?>

It will return 500 Internal Server Error after 120 seconds 120秒后它将返回500内部服务器错误

we have set the Max_execution_time=360 in php.ini, but the problem still exists. 我们在php.ini中设置了Max_execution_time = 360 ,但问题仍然存在。

We have Apache installed with FastCGI. 我们安装了FastCGI的Apache。

I am trying to extend it to 360 seconds, using .htaccess, because that is the only way i can in Shared Hosting. 我试图使用.htaccess将其扩展到360秒,因为这是我在共享主机中的唯一方法。

Any solutions or Suggestions ?, Thanks in Advance. 任何解决方案或建议?,提前致谢。

Fastcgi is a different beast; Fastcgi是一个不同的野兽; using set_time_limit will not solve the problem. 使用set_time_limit不会解决问题。 I'm not sure what you can do with .htaccess, but the normal setting you're looking for is called IPCCommTimeout; 我不知道你能用.htaccess做什么,但你正在寻找的正常设置称为IPCCommTimeout; you can try to change that in the .htaccess, I'm not sure if it's allowed or not. 你可以尝试在.htaccess中改变它,我不确定它是否被允许。

See the directives on the apache fcgid page ; 请参阅apache fcgid页面上的指令; if you're using an old version, you might need to try setting FcgidIOTimeout instead. 如果您使用的是旧版本,则可能需要尝试设置FcgidIOTimeout。

I would suggest that 120 seconds is far too long for a user to wait for a request over a web server; 我建议120秒对于用户等待Web服务器请求来说太长了; if things take this long to run, try running your script from the command line with PHP CLI instead. 如果事情需要很长时间才能运行,请尝试使用PHP CLI从命令行运行脚本。

试试这个,希望它能起作用:

set_time_limit(int seconds)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM