Nginx+php-fpm架构,遇到这个错误时:Request Entity Too Large 或 Nginx 413 Request Entity Too Large,须要作以下调整便可。php
一、修改配置一:Tune Nignx.conf setting:架构
# set client body size to 2M under http scope
client_max_body_size 2M;php-fpm
超时设置:
post
send_timeout 60; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300;
二、修改配置二:Tune php.ini settings:优化
;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32Mthis
;The maximum size of an uploaded file.
upload_max_filesize = 2Mcode
;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 3Mip
三、修改配置三:优化php-fpm配置内存
php_admin_value[memory_limit] = 1224Mit
3/28 UPDATE:假设上传1M的文件,若是代码中有对文件进行操做的,如写入,移动等,都php-fpm至少要再分配3倍的空间,如3M。若是是上传10M的文件,则要30M php-fpm内存。