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.