Topic: How do I set timeout when using Apache and PHP-FPM via SetHandler?
Hello,
Following the instructions at http://blog.famillecollet.com/post/2014 … mprovement , I have configured my Apache/PHP-FPM installation like this, where example.com is the domain for the site and each site has its own PHP-FPM process, and this code is in a VirtualHost for the site being represented:
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm/example.com.sock|fcgi://localhost"
</FilesMatch>
That works fantastic. It doesn't have all this issues of ProxyPassMatch. However, I recently encountered the situation where I need to set a higher timeout for Apache. I have a script that takes a few minutes to execute, and I want to enable that without getting a 503 Timeout/Service Unavailable. Currently, Apache sends a 503 after 30 seconds. I have confirmed that it is not PHP-FPM that is terminating the request (PHP continues to execute the request in the background).
I did some research and tried all of the following methods. None of the have worked. Apache still sends a 503 response after 30 seconds with each of these different "solutions".
#1:
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm/example.com.sock|fcgi://localhost timeout=300"
</FilesMatch>
#2:
<Proxy "unix:/var/run/php-fpm/example.com.sock|fcgi://localhost" timeout=300>
ProxySet timeout=300
</Proxy>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm/example.com.sock|fcgi://localhost"
</FilesMatch>
#3:
TimeOut 300
ProxyTimeout 300
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm/example.com.sock|fcgi://localhost"
</FilesMatch>
Do you have any proposed solution to this problem? I'd really like to keep using SetHandler instead of reverting back to ProxyPassMatch.
Thanks in advance!