Nginx出现403 forbidden (13: Permission denied)报错

Nginx出现403 forbidden (13: Permission denied)报错

使用Nginx部署前后分离项目时,访问时Nginx出现403 forbidden,发现Nginx日志文件报如下错误:

Nginx出现403 forbidden (13: Permission denied)报错

2021/09/10 11:31:25 [error] 42415#0: *1 "/home/web/web-d/index.html" is forbidden (13: Permission denied), client: 192.168.1.1, server: 192.168.1.101, request: "GET / HTTP/1.1", host: "192.168.1.101:5500"
2021/09/10 11:31:25 [error] 42415#0: *1 open() "/home/web/web-d/favicon.ico" failed (13: Permission denied), client: 192.168.1.1, server: 192.168.1.101, request: "GET /favicon.ico HTTP/1.1", host: "192.168.1.101:5500", referrer: "http://192.168.1.101:5500/"

发现启动用户和nginx工作用户不一致所致

于是将nginx.conf的user改为和启动用户一致

Nginx出现403 forbidden (13: Permission denied)报错

 

 将nginx.conf文件中的 user 对应的nginx用户改为 root ,改完后重启Nginx,页面即可正常访问!

说明:Nginx启动方式如下

cd /usr/local/nginx/sbin              进入Nginx下的sbin目录
./nginx -c /usr/local/nginx/conf/nginx.conf   执行启动命令
pkill nginx                      干掉Nginx

ps -ef | grep nginx                 查看Nginx

 

上一篇:flutter Cannot open file, path = ‘.../test.jpg‘ (OS Error: Permission denied, errno = 13)


下一篇:Hbase-10-权限管理