原因 1. SELinux為開啟狀態(enabled)
- 查看SELinux的狀態
sestatus
如果不是 disables , 需要
vi /etc/selinux/config
將以前的 SELINUX=enforcing 改為 SELINUX=disabled ,如下所示
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
保存后,reboot重啟系統即可。
注:這是個大坑!!!至於SELinux是什么請自行百度:)
原因 2. 權限問題
例如網站根目錄為 /var/www/html/ , 首頁文件為 /var/www/html/index.html
除了index.html文件根據需求設置權限,例如
chmod 644 /var/www/html/index.html
必須將這個文件所在的目錄設置為有 讀 和 操作 的權限
chmod -R 755 /var/www/html
注: 這個沒多大亂用,幾乎所有的文件(夾)都符合需要的權限。
原因 3. 沒有指定的文件index.html等
這個就不詳細舉例了,細心點不會在這里犯錯的,
在nginx配置文件里按需要寫上主頁名,別忘了后面的分號就行。
index index.php index.html;
------------------------PS--------------------------
這個問題沒把我急死,文件權限修改了無數次怎么也不行,終於發現是SELinux的鍋,既然暫時用不到這個東東,就將它禁用~~~
或許更改用戶組權限也可以解決這個問題,留待心情好了再看看~
________________END________________