I have the follow unresolved problem regarding PHP and Apache. I have a long running script that ALWAYS return 504 Gateway Timeout after 30 seconds running. However, if I check in /server-process
, I can see that the request is still going on. Before being suggested, I'm not expecting it to be a cron job as this long process should finish just under a minute and for current situation, I needed it to run inside browser. Here's what I've set the server:
/etc/apache2/apache2.conf
- Timeout 600
/etc/php/7.0/apache2/php.ini
- max_execution_time = 300
- max_input_time = 300
Here's my server info:
root@izzystorage-core:~# lsb_release -r
Release: 16.04
root@izzystorage-core:~# apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-09-18T15:09:02
root@izzystorage-core:~# php -v
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
Do you guys have any Idea what's going on with my server?
edit
- I don't have
mod_proxy
- This is only one server without load balancer in between
I have a Mysql query running in a PHP script that scans a lot of data and responds in 2 minutes. I was always getting 504 gateway timeout after 30 sec. After trying all usual advice, I ended up understanding that the issue was lying on the Open Shift route that I use to access the PHP script. The Open Shift default route Time out is 30 seconds. I changed the route annotation to 5 min and it did the trick ! See here for details: https://stackoverflow.com/questions/47812807/openshift-service-proxy-timeout
After several hours adjusting
Timeout
,max_execution_time
andmax_input_time
parameters and multipleservice apache2 restart
without result, I put back the original parameters (600, 300, 300) and restart the whole server withshutdown -r now
. Upon server back online, all problem suddenly resolved.