測試時遇到將一本地目錄設置為一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文件下找到這段:
- <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>
#
# 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 style="font-size: x-small;"># 允許指向外部的目錄進行訪問
- <Directory />
- Options Indexes FollowSymLinks
- AllowOverride None
- </Directory></span>
# 允許指向外部的目錄進行訪問
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
<Directory />
Options Indexes FollowSymLinks ExecCGI
AllowOverride None
</Directory>
然后重啟apache,就ok了。