Nginx教程

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

本文主要是介绍Nginx出现403 forbidden (13: Permission denied)报错,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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

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

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.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

 

这篇关于Nginx出现403 forbidden (13: Permission denied)报错的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!