linux+nginx+mysql+php system modified file upload size limit

Source: Internet
Author: User

linux+nginx+mysql+php system modified file upload size limit

for some sites of the LNMp Framework, the upload file size will be limited by many aspects, one is the limit of nginx itself, limit the size of the client upload file, will error "413 Request Entity Too Large" ; One is a setting in the php.ini file that defaults to multiple places.

1. In php.ini, make the following changes:
① File_uploads = On
③upload_max_filesize = 2m

④max_file_uploads = 20

it Parameter is a parameter that is added in php5.2.12 and later versions, which is the maximum number of uploads per set (Maximum numbers of files that can is uploaded via a single request), exceeding that number The file will be discarded. So setting the value of Max_file_uploads is the maximum number of files you can use to solve this problem successfully.

The maximum file upload limit is set to 20 by default, so the maximum upload is 20 documents, so more than 20 will be an error.

⑤ post_max_size = 8M

Modify the Post_max_size option in the php.ini configuration file, which represents the maximum byte length of data allowed for post, which defaults to 8M. If the post data exceeds the limit, then $_post and $_files will be empty. To upload a large file, you must set the value of the option to be greater than the upload_max_filesize instruction, and generally set the upload_max_filesize and post_max_size values equal. In addition, if memory limits are enabled, the value should be less than the value of the Memory_limit option.
⑥ max_execution_time
each PHP page runs the maximum Time value (seconds), default is 30 seconds, changed to max_execution_time = 0, 0 says there is no limit. when uploading large files, if the network speed is slow, when more than a certain time, the script executes more than 30 seconds of error, this is because in the php.ini configuration file max_execution_time configuration parameters, which represents the maximum allowable execution time per script (in seconds), 0 means there is no limit. You can adjust the value of the max_execution_time appropriately, and it is not recommended to set to 0.

⑦max_input_time = 1000

The maximum time that each PHP page takes to receive data, by default, is 60 seconds, which is the amount of time each script can consume, in seconds.

⑧memory_limit = 128M

The maximum memory eaten by each PHP page, the default 8M, which is the maximum memory consumed by the script, changes the value according to your needs.

2. Reload the PHP configuration file

Lnmp PHP is the fast-cgi mode, which is a separate service, so you have to restart PHP separately.
/USR/LOCAL/PHP/SBIN/PHP-FPM Reload

3. In nginx.conf, make the following changes:

client_max_body_size 35m;

represents the maximum number of single-file bytes allowed to be requested by the client. Find the client_max_body_size in the nginx.conf file, if not, add this, the following 120m is to specify the maximum support 120M size of the file. The location can be added to the HTTP module, or it can be labeled as a PHP page.

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
Location ~. php$ {
Root/home/www/htdocs;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/home/www/htdocs$fastcgi_script_name;
            includeFastcgi_params;
 
client_max_body_size 35m; #客户端上传文件大小设为35M
client_body_temp_path/home/www/nginx_temp; #设置临时目录
        }

4. Reload the Nginx configuration file

/usr/local/nginx/sbin/nginx-s Reload



Reference:

Http://www.111cn.net/sys/linux/61094.htm

Http://blog.sina.com.cn/s/blog_54d63a8b01017q9x.html

This article is from the "Mq_douer" blog, make sure to keep this source http://douer.blog.51cto.com/6107588/1917737

linux+nginx+mysql+php system modified file upload size limit

Related Article

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.