Errors 504 and 413 in fresh installation on NGINX server

577 views Asked by At

I have set up my first nginx server and in PhpMyAdmin i am getting the following errors:

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

I used the following line and install the nginx and php files.

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

I might not needed all, as my web application is a simple CRUD style base on PDO, MySQL.

I am reading in the site that i have to change-edit some congif but i can make it work.

Do i have to change them in NGINX, PHP, PHP-FPM?

What i must add/edit in here, NGINX:

/etc/nginx/sites-enabled/default

or here:

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

What i must add/edit in here, PHP:

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

What i must add/edit in here, PHP-FPM:

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

Do i need to make changes to another file, like ExecTimeLimit to 0 in PhpMyAdmin(where it is located) or any other?

I have found this for the time....

1

There are 1 answers

0
PeterPan2020 On

I followed this steps at it seems to work fine now.

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

Must of my problem solved but if i tried in PHPMyAdmin/SQL page, to insert 30K rows, i am getting error.

According to 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$

I am missing something?