Centos中的XAMPP環境中的web專案無法訪問 報錯403
宿主機訪問虛擬機器中的web專案報錯403
1,首先判斷是apache配置檔案許可權問題,於是做以下修改:
修改主配置檔案httpd.conf (我的目錄是 /opt/lampp/etc/httpd.conf)
找到:
<Directory />
AllowOverride none
Require all denied #引入所有的拒絕許可權
</Directory>
修改為:
<Directory />
AllowOverride all
Order allow,deny
Allow from all #允許所有訪問
Require all granted #引入所有的授權
</Directory>
2,再去虛擬主機 /opt/lampp/etc/extra/httpd-vhosts.conf中配置web站點(前提是在httpd.conf中引入了該配置)
<VirtualHost *:80>
DocumentRoot "/home/wwwroot/test"
ServerName www.test.com
ServerAlias www.test.com
ErrorLog "logs/www.test.com-error_log" #錯誤日誌
CustomLog "logs/www.test.com-access_log" common #訪問日誌
<Directory "/home/wwwroot/test">
DirectoryIndex index.php
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted #要求所有授權
</Directory>
</VirtualHost>
再次在宿主機(物理機)瀏覽器訪問 www.test.com發現還是報錯403
3,檢視錯誤日誌www.test.com-error_log"資訊:
[client 192.168.2.1:52395] AH00529: /home/wwwroot/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/wwwroot/' is executable, referer: http://www.test.com/
4,再次檢查了相關的配置檔案,許可權都已經給了,,,看來配置檔案是沒什麼問題,,,按著錯誤日誌上的提示檢查/home/wwwroot下確實沒有.htaccess檔案,於是給/home/wwwroot 755 許可權
解決:
chmod -R 755 /home/wwwroot/
後就可以了
總結一下403 Forbidden主要原因分析
1,客戶端IP被列入黑名單
2,在一定時間內過多地訪問此網站(一般是用採集程式),被防火牆拒絕訪問了 (測試服一般在搭建開發環境之前會關閉防火牆(永久))
3,網站域名解析到了空間,但空間未繫結此域名
4,網頁尾本檔案在當前目錄下沒有執行許可權 (對相應目錄chmod許可權 es: chmod -R 755 /home/wwwroot)
5,在不允許寫/建立檔案的目錄中執行了建立/寫檔案操作
6,伺服器繁忙,同一IP地址傳送請求過多,遭到伺服器智慧遮蔽