Problem: I'm using wordpress on LNMP environment. My site works just fine, but when installing themes / plugins, it does not work and reports a 504 error.
Bottom line:
Details When I run into the problem, I did what people normally do. I went to GOOGLE and set fastcgi_read_timeout to bigger values, as I remember this worked for me on other severs. This, however, only have me wait for 5 min before get the error report (300 s = 5 min). I also tried bigger fastcgi_buffer_size, which also did not work. I think this has something to do with installing theme or plugin, since the web page itself displays fine and error only occurs when installing.When installation failed, I find (not complete plugin) files in plugin folder.
Nginx error log:
2017/07/22 07:42:26 [error] 2672#2672: *283 upstream timed out (110:
Connection timed out) while reading response header from upstream,
client: my.client.ip.adderss, server: name.of_my_server, request:
"POST /wp-admin/admin-ajax.php HTTP/1.1", upstream:
"fastcgi://127.0.0.1:9000", host: "name.of_my_server", referrer:
"http://my.domain/wp-admin/plugin-install.php?s=best+CAPTCHA&tab=search&type=term"
(There are many entries similar to this one.)
Interestingly, wordpress displays error as:
Installation failed: 504 Gateway Time-out 504 Gateway Time-out
nginx/1.10.3 (Ubuntu) <!-- a padding to disable MSIE and Chrome
friendly error page --> <!-- a padding to disable MSIE and Chrome
friendly error page --> <!-- a padding to disable MSIE and Chrome
friendly error page --> <!-- a padding to disable MSIE and Chrome
friendly error page --> <!-- a padding to disable MSIE and Chrome
friendly error page --> <!-- a padding to disable MSIE and Chrome
friendly error page -->
Half of that message certainly should not be shown. Perhaps there is something wrong here.
php-fpm's log shows no error, neither does wordpress' log when enabling logging.
software versions
Any thoughts?
This issue is caused by setting cgi.fix_pathinfo to 0 in php.ini.The intention was to reduce security risks, but it can cause more problems.
cgi.fix_pathinfo = 1
Basically setting cgi.fix_pathinfo to 1 (leaving it as default) solved the problem, for correct and secure nginx + php-fpm configure, please see "PHP FastCGI Example". I also posted an article on my blog regarding how to solve the problem.
Changing cgi.fix_pathinfo
as per recommended solution didn't help me on Ubuntu 16. I noticed, that even when the error showed up, the theme or plugin still go installed though.
What helped me in the end was increasing PHP timeouts to higher value as per this guide. You wrote it didn't help you, but did you raise all the values?
After I raised max_execution_time
in php.ini, request_terminate_timeout
in php's www.conf and fastcgi_read_timeout
in vhost to 300, I am not getting the warnings anymore.