nginx:413 Request Entity Too Large

  • 2020-05-07 20:56:18
  • OfStack

Development environment: CentOS + Nginx + PHP + MySql + phpMyAdmin

When importing sql database with phpMyAdmin, it is often necessary to upload a large sql data file, and then it will often encounter nginx error: 413 Request Entity Too Large.

To solve this problem, you need to adjust the parameter configuration in two places according to the size of the uploaded data file:

1. The default upload size limit of php is 2M. If you exceed 2M, you need to modify the parameters in the php configuration file php.ini

post_max_size = 8M (the maximum limit for form submission, which does not limit the size of a single file to be uploaded, but the data for the entire form submission.)

upload_max_filesiz e = 2M (maximum limit on a single file uploaded)

You need to guarantee post_max_size > = upload_max_filesize, that is, the former is not less than the latter.

After modification 1 must restart php-fpm.

2. In addition to modifying the php configuration, you will also need to modify the nginx configuration file nginx.conf  

Open nginx configuration file nginx.conf, find http{} segment, add 1 line of configuration:

client_max_body_size 8m;
Among them, 8m can be set according to the need to upload the file size.

After modification 1 must be reloaded to nginx (service nginx reload).


Related articles: