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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章