Nginx + php Upload large file configuration parameters

Source: Internet
Author: User
Tags php and


Sometimes it is necessary to upload some large files. The old High server is nginx + php, both of which need to be configured.

Nginx

At the beginning, the old master only configured PHP and always reported an error every time a large file was transferred.

413 "Request Entity Too Large"

The reason is that nginx limits the size of the uploaded files on the client. The modification method is very simple. Just modify client_max_body_size to the required value!

# Search for client_max_body_size. If there are few configuration files, you do not need to search. Open the server segment of the configuration file directly.

Grep-nr client_max_body_size.


# Change to 200 M
Client_max_body_size 200 M;

# Save and restart nginx

Nginx-s reload
PHP

PHP needs to be modified in many places, mainly post_max_size and upload_max_filesize, as well as script execution time. We recommend that you modify it in the code at runtime, the method is set_time_limit (600); and there is also memory_limit to be modified, but there is no error at present!

RUN sed's/post_max_size = 8 M/post_max_size = 20000 M/'-I/usr/local/etc/php. ini \
& Sed's/upload_max_filesize = 2 M/upload_max_filesize = 20000 M/'-I/usr/local/etc/php. ini \
& Sed's/^; \ s * max_input_vars = 1000/max_input_vars = 10000/'-I/usr/local/etc/php. ini

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.