Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. It returns 500 Internal Server Error, exactly after 120 seconds.

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.

But when i place below script:

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

It will return 500 Internal Server Error after 120 seconds

we have set the Max_execution_time=360 in php.ini, but the problem still exists.

We have Apache installed with FastCGI.

I am trying to extend it to 360 seconds, using .htaccess, because that is the only way i can in Shared Hosting.

Any solutions or Suggestions ?, Thanks in Advance.

like image 854
Mahesh Avatar asked Sep 22 '26 11:09

Mahesh


1 Answers

Fastcgi is a different beast; using set_time_limit will not solve the problem. I'm not sure what you can do with .htaccess, but the normal setting you're looking for is called IPCCommTimeout; you can try to change that in the .htaccess, I'm not sure if it's allowed or not.

See the directives on the apache fcgid page; if you're using an old version, you might need to try setting FcgidIOTimeout instead.

I would suggest that 120 seconds is far too long for a user to wait for a request over a web server; if things take this long to run, try running your script from the command line with PHP CLI instead.

like image 163
El Yobo Avatar answered Sep 25 '26 00:09

El Yobo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!