Modify the size limit of Nginx + PHP files to be uploaded

Source: Internet
Author: User
Modify the size limit of Nginx + PHP files to be uploaded
This article describes how to modify the size limit of php files to be uploaded in nginx and php environments. this solution cannot exceed 2 MB for php files to be uploaded. For more information, see.

When uploading files in php, first modify the settings of php. ini, and then change the server environment (using nginx + php). it is found that files with a relatively large size cannot be uploaded.

The reason is that the client_max_body_size option value of nginx causes 413 errors.

Problem Description: In the php. ini configuration file, upload_max_filesize is set to 50Mpost_max_size and the value is 413 MB. However, if the file uploaded exceeds 10 MB, the uploaderror error is returned.

Server environment: centos5.7 32-bit nginx1.0.8php5.2.17

Solution: 1. if the file upload limit is 50 MB, modify php first. ini upload_max_filesize 50Mpost_max_size 100 M 2. modify the nginx configuration file: The default value of this configuration option is 1 m, which can be increased to 8 M to increase the file size limit.

You can directly change it to 100 here. you can set it based on your needs. (Reference: the client_max_body_size must be the same as the maximum values in upload_max_filesize and post_max_size in php. ini, or slightly larger. this will not cause errors due to inconsistent size of submitted data .)

Client_max_body_size 100 m;

Summary

In the case of the limit on the size of php files to be uploaded, in addition to the php configuration, the current server environment factors, such as the configuration items in nginx or apache, should also be considered.

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.