nginx報錯,首先查看nginx的日志。一般在nginx的logs的目錄下。
nginx出現403,不一定是權限問題,可能是缺少index文件,或者是缺少入口文件的配置。
1. directory index of "/usr/share/nginx/html/" is forbidden
1.1 如果在/usr/share/nginx/html下面沒有index.php,index.html的時候,直接訪問域名,找不到文件,會報403 forbidden。
解決辦法:添加文件即可
1.2 還有一個原因就是你的默認的nginx配置文件的location沒有指定root路徑,我的就是這個問題。
這個就直接在默認的server上面加上:
location / {
root html;
index index.php index.html index.htm;
}