Apache提示You don't have permission to access / on this server問題解決


測試時遇到將一本地目錄設置為一apache的虛擬主機,在httpd-vhosts.conf文件中進行簡單設置,然后在hosts文件中將訪問地址指向本地,啟動apache,進行訪問,卻出現了You don't have permission to access / on this server的提示,baidu了一下,原來是因為我的虛擬主機目錄為非apache安裝目錄下的htdocs,所以違反了apache對默認對網站根訪問權限。

apache的默認虛擬主機根目錄地址為../Apache Software Foundation/Apache2.2/htdocs 目錄下,需要對httpd.conf文件進行修改才能指向其他目錄。

 

在httpd.conf文件下找到這段:

 

 

 

Conf代碼 復制代碼  收藏代碼
  1. <span style="font-size: x-small;">#  
  2. # Each directory to which Apache has access can be configured with respect  
  3. # to which services and features are allowed and/or disabled in that  
  4. # directory (and its subdirectories).   
  5. #  
  6. # First, we configure the "default" to be a very restrictive set of   
  7. # features.    
  8. #  
  9. <Directory />  
  10.     Options FollowSymLinks  
  11.     AllowOverride None  
  12.     Order deny,allow  
  13.     Deny from all  
  14. </Directory></span>  

 

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

 

 將之修改為

 

 

 

Conf代碼 復制代碼  收藏代碼
  1. <span style="font-size: x-small;"># 允許指向外部的目錄進行訪問  
  2. <Directory />  
  3.     Options Indexes FollowSymLinks  
  4.     AllowOverride None  
  5. </Directory></span>  

 

# 允許指向外部的目錄進行訪問
<Directory />
    Options Indexes FollowSymLinks
    AllowOverride None
</Directory>

<Directory /> 
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
</Directory>

 然后重啟apache,就ok了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM