Question: I am attempting to setup Apache + PHP-FPM, however, we have a long running script that was executed and eventually timed out, which severed the link between Apache and FPM ultimately bringing down the whole site...

Is there anyway to prevent the whole site from coming down if the --idle-timeout is reached?

```
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -idle-timeout 18000 -pass-header Authorization

```

Answer: 
The Apache request to php-fpm [will be aborted when the timeout is reached](https://wiki.apache.org/httpd/HelpOnInstalling/FastCgi). Thus for the user as well. If you want the end client to get a response, there are three possibilities that come to mind:

1. increase your timeout value (since you PHP application is slower than that)
2. try to make your PHP application faster for that request
3. have your PHP application calculate the time it's taking and respond with an error message if it's taking longer than your timeout value

Solution #2 would be the usual developer choice IMHO.
Long running scripts should not be run from the browser/Apache. You should run it in the background with PHP CLI instead of FPM. CLI scripts do not timeout and do not interfere with Apache operation.

You can either schedule the script to run regularly by using cronjobs or you can make it trigger from the browser by doing something like writing a temporary file (for example, put a file called `run_script` in your website directory and remove it at the end of your script) of setting a flag in a database or other backend. 

When going for the second way, you still need a cronjob (which can run once every minute) that checks for the existence of this file/database entry and fire off the script when it is found (you could also create a listener that monitors this constantly instead of once every minute, but that is pretty intensive and probably overkill for most use cases).

Once it's fired off all you send back to your users is just a notice like "Hold on, we're processing your request. Please check back in a few minutes.". That way, they also do not need to keep their browser open to keep the request running and can just do other stuff in the meanwhile.