查看nginx的error.log日志。打開日志出現Permission denied:
1.啟動用戶和nginx的工作用戶不一致所致
查看nginx的啟動用戶,發現是www,而為是用root啟動的 ps aux | grep "nginx: worker process" | awk '{print $1}' www
www
... root
2將nginx.conf的user用戶改為和啟動用戶一樣
3.缺少index.html或者index.php文件,就是配置文件中index index.html index.htm這行中的指定的文件
如果在/home/wwwroot/xamsjb.com/public下面沒有index.php,index.html的時候,直接文件,會報403 forbidden
4.權限問題
修改/home/wwwroot/xamsjb.com/public權限問題,改為目錄的所屬用戶,重啟nginx即可。
chmod -R 777 /home/wwwroot/xamsjb.com/public
5.修改SELinux的配置為關閉狀態。
臨時關閉:setenforce 0
永久關閉:vi /etc/selinux/config,SELINUX=enforcing改為SELINUX=disabled