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