刚刚搭建了一个Discuz X3.2的论坛,上传小于1m的附件没问题,只要大于1m就会报下面的错误:

QQ20150210-1

我的环境为CentOS 7,nginx、php-fpm为yum安装。
可以参考下面方法尝试解决一下问题:

修改php配置

编辑/etc/php.ini
查找upload_max_filesize
默认是2M,有必要的话修改为你需要的值,我修改为20M:
upload_max_filesize = 20M
保存退出。

修改nginx配置

编辑/etc/nginx/nginx.conf
http {} 加入client_max_body_size值。
附上这个参数的介绍:

英文部分为nginx官网解释,中文为作者根据自己理解添加。

Syntax:client_max_body_size size;
Default:client_max_body_size 1m;
Context:http, server, location
Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size.

这个值是设置所能接收的最大请求体的大小。
这个值默认为1m。
如果将这个值设置为0,则不限制。
这个值可以添加到http, server, location中都可以生效。
根据请求头中的Content-Length来判断请求体大小是否允许。如果大于设定值,则返回“ Request Entity Too Large”(413)错误。不过要注意的是,浏览器一般并不对这个错误进行特殊显示。

参考我的配置:

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;
    client_max_body_size 20m;         #这一行
    
    include /etc/nginx/conf.d/*.conf;
}
重启服务

systemctl restart php-fpm
systemctl restart nginx