PHP上传文件大小限制的调整 Nginx 413 Request Entity Too Large

Nginx+php-fpm架构,遇到这个错误时:Request Entity Too Large 或 Nginx 413 Request Entity Too Large,需要做如下调整即可。

1、修改配置一:Tune Nignx.conf setting:

# set client body size to 2M under http scope
client_max_body_size 2M;

超时设置:
 

send_timeout    60;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

2、修改配置二:Tune php.ini settings:

;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32M

;The maximum size of an uploaded file.
upload_max_filesize = 2M

;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 = 3M

 

3、修改配置三:优化php-fpm配置

php_admin_value[memory_limit] = 1224M

3/28 UPDATE:假设上传1M的文件,如果代码中有对文件进行操作的,如写入,移动等,都php-fpm至少要再分配3倍的空间,如3M。如果是上传10M的文件,则要30M php-fpm内存。

转载于:https://my.oschina.net/swingcoder/blog/1828370

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值