PHP and Nginx file upload size limit problem solving method

Source: Internet
Author: User
Tags http file upload
This article mainly introduces the PHP and nginx file upload size limit problem solving method, has a certain reference value, now share to everyone, the need for friends can refer to

For some sites in nginx+php, the upload file size will be limited by many aspects, one is the limitations of nginx itself, limit the size of the client upload file, one is the php.ini file default in many places of the settings. So in order to solve the problem of uploading file size limit, we must make many changes. Here are a few places to organize.

1, modify the/usr/local/nginx/conf/nginx.conf file, look for client_max_body_size set the value below to the value you want to set. Like what:

# 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;            Include        Fastcgi_params;            Client_max_body_size 35m;        #客户端上传文件大小设为35M            client_body_temp_path/home/www/nginx_temp;        #设置临时目录        }

2, modify the php.ini

Check the following line in the php.ini:

Upload_max_filesize = 8M Post_max_size = 10M Memory_limit = 20mmax_execution_time=300file_uploads = On default allow HTTP file upload, This option cannot be set to OFF. Upload_tmp_dir =/tmp/www

When uploading large files, you will have a slow upload feeling, when more than a certain time, will report the script to execute more than 30 seconds of error, because in the php.ini configuration file
Max_execution_time configuration options in mischief, 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.

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.