Apache 下更改 DocumentRoot 和新建虚拟目录
Apache 安裝后,默認的 DocumentRoot 是安裝目錄下的 htdocs 目錄,編程時有很多不便,如需更改,打開安裝目錄 conf 子目錄下的 httpd.conf 文件,修改 DocumentRoot 屬性即可,如更改為:DocumentRoot “E:/My/DocRoot”。
在 IIS 下,新建虛擬目錄可通過可視化界面操作,在 Apache 中,新建虛擬目錄通過修改 httpd.conf 文件實現。
在 httpd.conf 的 alias_module 下增加一別名定義項,如:Alias “/onefly” “E:/My/Onefly” ,即可定義虛擬目錄。
更改以上設置后,必須重啟 Apache 才能使設置生效。同時,要對相應目錄作權限定義,否則會出現無權訪問的錯誤提示。
要對目錄定義權限,可在 httpd.conf 文件中定義類似以下的代碼:
<Directory “E:/My/Onefly”>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
=======================================================================
自己機器上配置實例如下:
????#
????#?Redirect:?Allows?you?to?tell?clients?about?documents?that?used?to?
????#?exist?in?your?server's?namespace,?but?do?not?anymore.?The?client?
????#?will?make?a?new?request?for?the?document?at?its?new?location.
????#?Example:
????#?Redirect?permanent?/foo?http://www.waydu.com/bar
????#
????#?Alias:?Maps?web?paths?into?filesystem?paths?and?is?used?to
????#?access?content?that?does?not?live?under?the?DocumentRoot.
????#?Example:
????#?Alias?/webpath?/full/filesystem/path
????##################################################################
?????Alias???/study???"D:/PHP/www/study"??
????<Directory???"D:/PHP/www/study">???
??????????????Options???Indexes???Includes???FollowSymLinks???MultiViews???IncludesNoExec???
??????????????AllowOverride???None???
??????????????Order???allow,deny???
??????????????Allow???from???all???
????</Directory>??
????##################################################################
?
總結
以上是生活随笔為你收集整理的Apache 下更改 DocumentRoot 和新建虚拟目录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一起学DHCP系列(五)指派、获取
- 下一篇: FastReport分页和空行填充