【问题标题】:wordpress reports 504 Gateway Time-out (nginx) when installing themes / pluginswordpress 在安装主题/插件时报告 504 Gateway Time-out (nginx)
【发布时间】:2018-08-25 20:21:27
【问题描述】:

问题: 我在 LNMP 环境中使用 wordpress。我的网站运行正常,但是在安装主题/插件时,它无法运行并报告 504 错误。

底线:

  1. Nginx 和 php(至少有时)可以正常通信,因为我可以看到 我的网站正常显示。
  2. FTP 主机、用户名和密码正确,因为在安装主题或插件时,(至少有一些)文件被下载到主题或插件文件夹中(但不是整个主题或插件)。
  3. FTP 用户和 Nginx 用户确实有权访问该文件夹,该文件夹归 FTP 用户所有。 (FTP和Nginx用户在同一组,文件夹设置为775)
  4. 我尝试了更大的 fastcgi_read_timeout 值(例如 300),但没有帮助。

详情 当我遇到问题时,我做了人们通常会做的事情。我去了 GOOGLE 并将 fastcgi_read_timeout 设置为更大的值,因为我记得这在其他服务器上对我有用。但是,这只让我等待 5 分钟,然后才能收到错误报告(300 秒 = 5 分钟)。我还尝试了更大的 fastcgi_buffer_size,但也没有用。我认为这与安装主题或插件有关,因为网页本身显示正常并且仅在安装时出现错误。安装失败时,我在插件文件夹中找到(不完整的插件)文件。

Nginx 错误日志:

 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"

(有很多类似的条目。)

有趣的是,wordpress 显示错误为:

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 -->

该消息的一半当然不应该显示。也许这里有问题。

php-fpm 的日志没有显示错误,wordpress 的日志在启用日志记录时也没有。

软件版本

  • nginx 1.10.3
  • mysql Ver 14.14 Distrib 5.7.19
  • PHP 7.0.18-0ubuntu0.16.04.1
  • wordpress 4.8
  • Ubuntu 16.04.2 LTS

有什么想法吗?

【问题讨论】:

  • PHP 内存限制是如何设置的?只是为了确认,据我所知,您使用的是 php7.0-fpm,对吗?
  • @morre 这是正确的。我正在使用 php7.0-fpm。 php 内存限制在 php.ini 中设置为 128M,我还添加了 'define('WP_MEMORY_LIMIT', '128MB');'最后是 wp-config.php。

标签: php wordpress nginx ftp


【解决方案1】:

此问题是由于在php.ini中将cgi.fix_pathinfo设置为0造成的。本意是降低安全风险,但可能会导致更多问题。

cgi.fix_pathinfo = 1

基本上将 cgi.fix_pathinfo 设置为 1(保留它为默认值)解决了问题,正确和安全的 nginx + php-fpm 配置,请参阅"PHP FastCGI Example"。 我也posted an article on my blog关于如何解决这个问题。

【讨论】:

    【解决方案2】:

    根据推荐的解决方案更改 cgi.fix_pathinfo 在 Ubuntu 16 上对我没有帮助。我注意到,即使出现错误,主题或插件仍然会安装。

    最终帮助我的是根据this guide 将 PHP 超时增加到更高的值。你写的对你没有帮助,但你提出了所有的价值观吗?

    在我将 php.ini 中的 max_execution_time、php 的 www.conf 中的 request_terminate_timeout 和 vhost 中的 fastcgi_read_timeout 提高到 300 之后,我不再收到警告了。

    【讨论】:

      猜你喜欢
      • 2012-10-09
      • 2021-08-10
      • 2021-05-12
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      • 2011-09-28
      • 2019-06-24
      • 1970-01-01
      相关资源
      最近更新 更多