Nginx 首頁出現 403 forbidden
1. 出現的現象
查看 Nginx 日誌: 路徑爲 nginx 安裝路徑下 /logs/error.log 文件中.
2020/03/26 17:04:43 [error] 23045#0: *1 “/mnt/data/ngnix/ngnix/nginx/html/index.html” is forbidden (13: Permission denied), client: 117.179.241.44, server: localhost, request: “GET / HTTP/1.1”, host: “xx.xxx.xxx.xxx”
2. 解決方法
2.1 登錄 Linux 的用戶運行 Nginx 和 Nginx 工作用戶不一致
登錄 Linux 的用戶:
root
, 所以把 nginx.conf 中 user 改爲root
2.1 Nginx 缺少對 web 目錄的操作的權限
假設 web 目錄爲: /var/www/html
chmod -R 777 /var/www/html
3. 檢查, 重啓 Nginx
nginx -t
nginx -s reload