Example of modifying the size limit of uploaded files in the nginx environment

Source: Internet
Author: User

Modify php first

Modify php. ini

Open php. ini and modify the following two parameters. The parameter value is the maximum size of the files to be uploaded.

The code is as follows: Copy code

Post_max_size = 125 M
Upload_max_filesize = 120 M
Max_execution_time = 90

1. post_max_size: specifies the maximum size allowed by POST data.

2. upload_max_filesize: indicates the maximum size of the uploaded file.

3. max_execution_time: It takes time to upload a file. This value is the default timeout value of php. If it is set to 0, it will not time out (it is recommended not to set this value ), if the file has not been uploaded after the time-out period expires, the upload will also fail. Therefore, when modifying the size limit of the file to be uploaded, adjust this parameter as appropriate, otherwise, the upload will fail.

Post_max_size is slightly larger than upload_max_filesize.

Modify nginx file size limit

The code is as follows: Copy code

# Locate nginx. conf
/Alidata/server/nginx-1.0.4/conf/nginx. conf
/Alidata/server/nginx-1.0.4/conf/nginx. conf. default
# Locate php. ini
/Alidata/server/Zend/etc/php. ini
/Alidata/server/php-5.2.17/etc/php. ini
/Alidata/server/php-5.2.17/etc/php. Ini-zend_optimizer.bak

Modify nginx. conf

Client_max_body_size 120 m;

Find client_max_body_size in The nginx. conf file. If no value exists, add this file. The 120m file is the file with a maximum size of MB.

Restart nginx and php.

Nginx restart

First Look for the location where nginx is located. If you know the installation location is the best, see the following command if you do not know the location.

The code is as follows: Copy code

# Locate nginx | grep sbin
/Alidata/server/nginx-1.0.4/sbin
/Alidata/server/nginx-1.0.4/sbin/nginx

The following figure shows the Restart command for nginx. Before the restart, run the-t option to test whether the syntax of the configuration file is correct.

The code is as follows: Copy code

#/Alidata/server/nginx-1.0.4/sbin/nginx-t
#/Alidata/server/nginx-1.0.4/sbin/nginx-s reload

Php restart

The code is as follows: Copy code
/Etc/init. d/php-fpm restart

After modifying the php. Ini file, run the preceding command to restart php.

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.