title: wordpress reports 504 Gateway Time-out (nginx) when installing themes / plugins
body: <p><strong>Problem:</strong>
  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.</p>
  
  <p><strong>Bottom line:</strong></p>
  
  <ol>
  <li>Nginx and php (at least sometimes) communicate fine, since I can see
  my site display normally.</li>
  <li>FTP host, user name and password are correct, since when installing themes or plugins, (at least some) files are downloaded into theme or plugin folder (but not the whole theme or plugin). </li>
  <li>FTP user and Nginx user do have permission to access to the folder, which is owned by FTP user. (FTP &amp; Nginx users are in same group and the folder is set to 775)</li>
  <li>i tried bigger fastcgi_read_timeout values (e.g. 300), but it did not help.</li>
  </ol>
  
  <p><strong>Details</strong>
  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.</p>
  
  <p><strong><em>Nginx error log:</em></strong></p>
  
  <pre><code> 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&amp;tab=search&amp;type=term"
  </code></pre>
  
  <p>(There are many entries similar to this one.)</p>
  
  <p>Interestingly, wordpress displays error as:</p>
  
  <pre><code>Installation failed: 504 Gateway Time-out 504 Gateway Time-out
  nginx/1.10.3 (Ubuntu) &lt;!-- a padding to disable MSIE and Chrome
  friendly error page --&gt; &lt;!-- a padding to disable MSIE and Chrome
  friendly error page --&gt; &lt;!-- a padding to disable MSIE and Chrome
  friendly error page --&gt; &lt;!-- a padding to disable MSIE and Chrome
  friendly error page --&gt; &lt;!-- a padding to disable MSIE and Chrome
  friendly error page --&gt; &lt;!-- a padding to disable MSIE and Chrome
  friendly error page --&gt;
  </code></pre>
  
  <p>Half of that message certainly should not be shown. Perhaps there is something wrong here.</p>
  
  <p>php-fpm's log shows no error, neither does wordpress' log when enabling logging.</p>
  
  <p><strong>software versions</strong></p>
  
  <ul>
  <li>nginx 1.10.3</li>
  <li>mysql  Ver 14.14 Distrib 5.7.19</li>
  <li>PHP 7.0.18-0ubuntu0.16.04.1</li>
  <li>wordpress 4.8</li>
  <li>Ubuntu 16.04.2 LTS</li>
  </ul>
  
  <p>Any thoughts?</p>