wordpress博客上传文件--(linux运维20)

1. 413 Request Entity Too Large错误

当我们上传大于2m的时候就会出现这个错误。
解决办法:

1.1 修改nginx的配置文件

模块:client_max_body_size
https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

语法:

Syntax:	client_max_body_size size;
Default:	
client_max_body_size 1m;
Context:	http, server, location

所以修改配饰文件,加上:

client_max_body_size 50m;
server {
       listen        80;
       server_name   blog.yq.com;
       client_max_body_size 50m;
        error_log  /var/log/nginx/error_blog.log error;
       location  / {
         root  /html/blog;
         index index.php  index.html;
       }
       location ~ \.php$ {
                root /html/blog;
                fastcgi_index index.php;          
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass  127.0.0.1:9000;
                include fastcgi_params;
       }
    }

重启nginx在进行测试:

systemctl restart nginx

1.1.1 错误 500 Internal Server Error

修改好了上传的文件的大小之后,会出现500 Internal Server Error错误:

2021/09/19 11:51:25 [crit] 9291#9291: *1 open() "/var/lib/nginx/tmp/client_body/0000000001" failed (13: Permission denied), client: 192.168.246.1, server: blog.yq.com, request: "POST /wp-admin/update.php?action=upload-theme HTTP/1.1", host: "blog.yq.com", referrer: "http://blog.yq.com/wp-admin/theme-install.php?browse=popular"

是"/var/lib/nginx/tmp/client_body/0000000001" failed (13: Permission denied),目录的权限问题:

ll -d /var/lib/nginx/tmp
drwxrwx--- 7 nginx root 78 Jun 25 13:44 /var/lib/nginx/tmp

发现该目录的用户是nginx,而管理nginx我们设置的是www,所以修改目录权限即可

chown www.www  -R /var/lib/nginx/

systemctl restart nginx

1.2 然后再进行上传

在这里插入图片描述

需要配置PHP的上传的文件大小超过php.ini文件中定义的upload_max_filesize值。

vim /etc/php.ini 
/upload_max_filesize 
upload_max_filesize = 10M
systemctl restart php-fpm

1.3 完成上传

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

长安有故里y

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值