【问题标题】:Errors 504 and 413 in fresh installation on NGINX server在 NGINX 服务器上全新安装时出现错误 504 和 413
【发布时间】:2021-03-24 04:19:49
【问题描述】:

我已经设置了我的第一个 nginx 服务器,在 PhpMyAdmin 中我收到以下错误:

  • Error 413 - Request Entity Too Large
  • Error 504 - Gateway Timeout Reloaded

我使用以下行并安装了 nginx 和 php 文件。

sudo apt-get install nginx php7.3 php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-mbstring php7.3-cli 
       php7.3-common php7.3-curl php7.3-zip php7.3-xml php7.3-json php7.3-opcache php7.3-readline

我可能不需要全部,因为我的 Web 应用程序是基于 PDO、MySQL 的简单 CRUD 样式。

我在网站上读到我必须更改 - 编辑一些 congif,但我可以让它工作。

我必须在 NGINX、PHP、PHP-FPM 中更改它们吗?

我必须在此处添加/编辑的内容,NGINX:

/etc/nginx/sites-enabled/default

或这里:

/etc/nginx/nginx.conf
client_max_body_size = 0; in the server section

我必须在此处添加/编辑的内容,PHP:

/etc/php/7.3/cli/php.ini
max_execution_time = 600
upload_max_filesize = 15M
post_max_size = 15M

我必须在此处添加/编辑的内容,PHP-FPM:

/etc/php/7.3/fpm/php.ini
request_terminate_timeout = 600
upload_max_filesize = 15M
post_max_size = 15M

我是否需要更改另一个文件,例如 PhpMyAdmin(它所在的位置)或任何其他文件中的 ExecTimeLimit0

我暂时发现了这个......

【问题讨论】:

    标签: php nginx phpmyadmin http-status-code-504 http-status-code-413


    【解决方案1】:

    我按照这些步骤操作,现在似乎可以正常工作了。

    ### PhpMyAdmin - Error 413(Request Entity Too Large)
    ### PhpMyAdmin - Error 504(Gateway Timeout Reloaded)
    ### Edit "Nginx" Config File:
    sudo nano /etc/nginx/nginx.conf
    ### Add The Following Lines, Inside Http{} On Top:
    # Fix Error 413: Request Entity Too Large
    client_max_body_size 20M;
    ### Edit "Nginx/Sites-Enabled" Config File:
    sudo nano /etc/nginx/sites-enabled/default
    ### Add The Following Lines, Inside Server{} On Top.
    # Fix Error 413: Request Entity Too Large
    client_max_body_size 20M;
    ### Edit The Following Lines, Inside Server{location ~ \.php$ {}}.
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
    #       # With php-fpm (or other unix sockets):
            fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
            # Fix TimeOut Error   <=== Add This One ===>
            fastcgi_read_timeout 600;   <=== Add This One ===>
    #       # With php-cgi (or other tcp sockets):
    #       fastcgi_pass 127.0.0.1:9000;
        }
    ### Edit "PHP.ini" File:
    sudo nano /etc/php/7.3/cli/php.ini
    ### Find Lines And Edit:
    max_execution_time = 600
    upload_max_filesize = 20M
    post_max_size = 20M
    ### Edit "PHP-FPM" File:
    sudo nano /etc/php/7.3/fpm/php.ini
    ### Find Lines And Edit:
    max_execution_time = 600
    upload_max_filesize = 20M
    post_max_size = 20M
    ### Reload "Nginx" And "PHP7.3-FPM"(or Restart):
    sudo service php7.3-fpm reload
    sudo service nginx reload
    

    我的问题必须解决,但如果我尝试在 PHPMyAdmin/SQL 页面中插入 30K 行,我会收到错误。

    根据error.log

    2020/12/13 20:17:01 [error] 3920#3920: *262 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.0.19.67, $
    2020/12/13 20:33:19 [notice] 13839#13839: signal process started
    2020/12/13 20:38:45 [error] 13840#13840: *264 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /usr$
    

    我错过了什么?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 2012-01-12
      • 1970-01-01
      • 2015-06-08
      • 2017-11-24
      • 2021-05-08
      • 2018-09-29
      相关资源
      最近更新 更多