Home > Backend Development > PHP Tutorial > How to solve the file upload size limit of PHP and Nginx

How to solve the file upload size limit of PHP and Nginx

WBOY
Release: 2016-07-25 08:54:51
Original
1226 people have browsed it
  1. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

  2. #
  3. location ~ .php$ {
  4. root /home/www/htdocs;
  5. fastcgi_pass 127.0.0.1:9000 ;
  6. fastcgi_index index.php;
  7. fastcgi_param SCRIPT_FILENAME /home/www/htdocs$fastcgi_script_name;
  8. includefastcgi_params;

  9. client_max_body_size 35m;#Client upload file size is set to 35M

  10. client_body_temp_path /home/www /nginx_temp;#Set the temporary directory
  11. }

Copy the code

2. Modify php.ini View in php.ini:

  1. upload_max_filesize = 8M
  2. post_max_size = 10M
  3. memory_limit = 20M
  4. max_execution_time=300
  5. file_uploads = On
Copy code

Allow HTTP files by default Upload, this option cannot be set to OFF. upload_tmp_dir =/tmp/www

When uploading large files, the upload speed will feel slow. When it exceeds a certain time, an error will be reported that the script execution exceeds 30 seconds. Modify the max_execution_time configuration option in the php.ini configuration file, which indicates the maximum execution time of each script. Allowed execution time (seconds), 0 means no limit.

The value of max_execution_time can be adjusted appropriately. Setting it to 0 is not recommended.

After completing the above two modifications, you can basically solve the problem of PHP upload file size limit.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template