Apache提示You don't have permission to access / on this server問題解決
今天為了方便測試,將一本地目錄設(shè)置為一apache的虛擬主機,在httpd-vhosts.conf文件中進行簡單設(shè)置,然后在hosts文件中將訪問地址指向本地,啟動apache,進行訪問,卻出現(xiàn)了You don't have permission to access / on this server的提示,baidu了一下,原來是因為我的虛擬主機目錄為非apache安裝目錄下的htdocs,所以違反了apache對默認(rèn)對網(wǎng)站根訪問權(quán)限。
apache的默認(rèn)虛擬主機根目錄地址為../Apache Software Foundation/Apache2.2/htdocs 目錄下,需要對httpd.conf文件進行修改才能指向其他目錄。
在httpd.conf文件下找到這段:
- <span style="font-size: x-small;">#
- # 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></span>
將之修改為
- <span style="font-size: x-small;"># 允許指向外部的目錄進行訪問
- <Directory />
- Options Indexes FollowSymLinks
- AllowOverride None
- </Directory></span>