nginx 403 Forbidden错误的原因和解决方法
程序员文章站
2022-05-29 22:25:52
...
问题总是等着自己去解决,刚弄了下nginx开机自启动和开机禁用防火墙,可是在浏览器访问却报了403 Forbidden错误。
查看错误日志,发现是权限不足导致的。
[[email protected] logs]# cat error.log
2018/04/13 08:54:50 [emerg] 1179#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/04/13 08:54:50 [emerg] 1179#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/04/13 08:54:50 [emerg] 1179#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/04/13 08:54:50 [emerg] 1179#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/04/13 08:54:50 [emerg] 1179#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/04/13 08:54:50 [emerg] 1179#0: still could not bind()
2018/04/13 08:55:03 [notice] 1180#0: signal process started
2018/04/13 10:02:45 [error] 918#0: *1 "/root/hbk/nginx2//html/index.html" is forbidden (13: Permission denied), client:uest: "GET / HTTP/1.1", host: "192.168.254.128"
2018/04/13 10:02:45 [error] 918#0: *1 open() "/root/hbk/nginx2//html/favicon.ico" failed (13: Permission denied), clienequest: "GET /favicon.ico HTTP/1.1", host: "192.168.254.128", referrer: "http://192.168.254.128/"
2018/04/13 10:02:52 [error] 918#0: *1 "/root/hbk/nginx2//html/index.html" is forbidden (13: Permission denied), client:uest: "GET / HTTP/1.1", host: "192.168.254.128"
2018/04/13 10:02:52 [error] 918#0: *1 open() "/root/hbk/nginx2//html/favicon.ico" failed (13: Permission denied), clienequest: "GET /favicon.ico HTTP/1.1", host: "192.168.254.128", referrer: "http://192.168.254.128/"
2018/04/13 10:03:05 [error] 918#0: *1 "/root/hbk/nginx2//html/index.html" is forbidden (13: Permission denied), client:uest: "GET / HTTP/1.1", host: "192.168.254.128"
网上看了相关几篇博客,才知道是因为配置文件conf/nginx.conf文件的执行用户和当前用户不一致导致的,把之前的nobody改成当前用户root。
user root;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
重启配置即可,问题完美解决。
推荐阅读
-
nginx403错误怎么解决(nginx转发请求403的原因)
-
nginx403错误怎么解决(nginx转发请求403的原因)
-
Nginx 502 Bad Gateway错误常见的4种原因和解决方法
-
权限问题导致Nginx 403 Forbidden错误的解决方法
-
Nginx服务器中414错误和504错误的配置解决方法
-
Nginx报403 forbidden错误 (13: Permission denied)的解决办法
-
权限问题导致Nginx 403 Forbidden错误的解决方法
-
Nginx 502 Bad Gateway错误常见的4种原因和解决方法
-
nginx 403 Forbidden错误的原因和解决方法
-
Nginx报403 forbidden错误 (13: Permission denied)的解决办法