WordPress上传文件大小限制修改

WordPress对上传文件的大小会有一定限制,可通过如下方法进行修改:

1、 修改PHP配置文件/etc/php.ini

file_uploads = on ;
upload_max_filesize = 2G ;
post_max_size = 2G ;

2、修改 Nginx 配置文件/etc/nginx/nginx.conf(如果用的是 Nginx 服务器的话),添加

client_max_body_size 2G;  # 允许上传 2G

一个完整的示例如下:

server {
    server_name yourdomain.com;
    listen 80;
    # root /usr/share/nginx/wordpress;
    return 301 https://$server_name$request_uri;
}

server {
    server_name yourdomain.com; #填写绑定证书的域名
    listen 443;
    root /usr/share/nginx/wordpress;
    ssl on;
    ssl_certificate /etc/nginx/cert/server.crt;
    ssl_certificate_key /etc/nginx/cert/server.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
    ssl_prefer_server_ciphers on;
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php index.php;
    }
    location ~ .php$ {
        proxy_pass     https://127.0.0.1:8080;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        client_max_body_size 5G;   # 一定要在这里才有效
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

注:如果出现HTTP错误,还应检查WordPress程序目录下 /wp-content/uploads 目录的权限。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值