Modifying the configuration truly solves the php file upload size restriction problem (nginx + php) _ php instance

Source: Internet
Author: User
Tags php file upload
For some websites in nginx + php, the size of the uploaded files is limited in many ways. One is the size of the files uploaded by nginx, which is limited by the size of the files uploaded by the client. The other is php. by default, the INI file has settings in multiple locations. Therefore, you must modify the size of the uploaded file in multiple places to solve the problem. The following are some documents.
max_execution_time = 300max_input_time = 600

I have already discussed how to solve the php file upload size limit in apache + php. For nginx + php websites, the difference from how to solve the php file upload size limit in apache + php is the nginx restrictions, which limit the size of files uploaded by the client, nginx is used as an example to illustrate how to solve this problem in nginx + php.

1. Modify nginx configuration items

Modify the/usr/local/nginx/conf/nginx. conf file to find the client_max_body_size file and set the value to be set. For example:

Location ~ \. Php $ {root/home/www/htdocs; fastcgi_pass www.169it.com; fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME/home/www/htdocs $ fastcgi_script_name; include fastcgi_params; limit 10 m; # Set the size of the uploaded file on the client to Bytes/home/www/nginx_temp}

2. Modify php configuration items

You also need to modify php according to the actual situation. max_execution_time (maximum execution time of php pages), max_input_time (maximum time for receiving data on php pages), and memory_limit (maximum memory occupied by php pages) in the ini configuration file), upload_max_filesize, and post_max_size.

Modify the php. ini configuration file

upload_max_filesize = 20Mpost_max_size = 30Mmemory_limit = 256M

If the file is too large, there may be time issues. If necessary, make the following changes:

max_execution_time = 300max_input_time = 600

The above content is the article about modifying the configuration to truly solve the php file upload size limit (nginx + php). I hope you will like it.

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.