2

我已经设置了我的第一个 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

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

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

4

1 回答 1

0

我遵循了这个步骤,现在它似乎工作正常。

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

我错过了什么?

于 2020-12-13T16:20:45.400 回答