Nginx http:413 Request Entity Too Large Solution _nginx

Source: Internet
Author: User

Overview

Today encountered a problem, in the PHP program upload picture has the following error: http:413 Request Entity Too Large.

Development environment: CentOS + Nginx + PHP + MySql

Solution

To solve this problem, depending on the size of the uploaded data file, you need to adjust the configuration of PHP and Nginx related parameters.

Configure PHP

PHP default upload file size limit of 2M, if more than 2M you need to modify the PHP configuration file php.ini inside the parameters.

Copy Code code as follows:

Post_max_size = 8M (the maximum limit for form submissions, which is not to limit the size of an uploaded individual file, but to limit the data submitted by the entire form). )
Upload_max_filesize = 2M (maximum limit of individual files uploaded)
Need to guarantee post_max_size >= Upload_max_filesize, namely the former is not less than the latter.
Be sure to restart PHP-FPM after the modification.

Configure Nginx

In addition to modifying the PHP configuration, you also need to modify the Nginx configuration file nginx.conf.

Copy Code code as follows:

Client_max_body_size 30M;

30M can be uploaded according to the size of the file itself set.
Be sure to reload the Nginx (service nginx restart) after the modification.

Summarize

Today solved several small problems, each record ~ ~
No more progress, a little bit every day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.