nginx 504 Gateway time-out with php.ini changed - works on local homestead
Hi all,
I can't figure this out -
I'm using snappy pdf to create a large pdf doc with images. the task is done within 30secs most times, and it always works as expected unless the process takes longer than 30secs. I changed all relevant php.ini settings on my forge ( /etc/php71/fpm/php.ini) and on homestead. It works on my local homestead but my production on forge always fails if it takes longer than 30 secs to create. This makes me believe Forge is ignoring the php.ini file? I checked and my server is using /etc/php5/fpm/php.ini which is the file that has changed. I have restarted php and nginx but I don't understand what could be happening.
And you're sure you restarted the php7.1-fpm service?
You could also just set it in your code, so it won't matter what php.ini is. This is more portable across environments as well since you don't have to alter php.ini.
Try editing the php.ini through the interface of forge it self. You can do this by clicking on 'files' at the bottom.
And as a suggestion/must do: update your local environment to PHP 7.1 so it matches your production environment. Having differences in PHP between environments is a bad idea for different reasons.
Thanks all, I've tried everything above. set_time_limit(300); works great on my dev homestead but of course not on my forge production. It's nice that there's the php.ini edit on the forge env … unfortunate it just displays what I already edited on the server.
Is there any nginx setting I can add to limit timeout? I'm not familiar with the settings but forge has a Edit for it. But then again, why is it working on my dev and not production if the only thing different is the location of the php.ini settings - which are the same on both.
Are you editing "PHP FPM", or "PHP CLI" from Forge? It should be PHP FPM, but really it shouldn't matter since set_time_limit() overrides default settings. I use set_time_limit() in my code on a Forge server for a method that is a long running process, and it adheres to it.
Honestly, I have both changed right now in hopes one would work. Like you said, I hoped set_time_limit() would overwrite it just like it does on my dev environment with homestead.
Is there anything in nginx.conf I should be adding/changing to try?
I'm sorry, I can't think of anything else at this point. I'd try contacting Forge Support (blue circle in lower-right hand corner when logged into Forge).