如何設置修改Apache文件根目錄設置
2016-01-15 15:53:36
10153
在安裝 Apache 時,系統會給定一個缺省的文件根目錄。
如果你覺得將網頁存在這個缺省目錄不方便,覺得應該另外設個目錄作為 Apache 文件根目錄,你可以修改 Apache 的配置文件 httpd.conf 里有關文件根目錄的設置。
假設Apache HTTP Server 的缺省文件根目錄 (DocumentRoot) 是:
DocumentRoot "F:ampApache2.2htdocs"
修改 Apache 文件根目錄 (DocumentRoot) 的操作如下:
1. 為避免修改失誤,請先備份你的 Apache 配置文件 httpd.conf,該配置文件的路徑是:
F:ampApache2.2htdocs
2. 打開 http.conf 文件,找到 DocumentRoot 為開頭的那一行,將
DocumentRoot "F:ampApache2.2htdocs"
改成新的 DocumentRoot 路徑,比如你新的路徑為 C:htdocs,就改成
DocumentRoot "C:/htdocs"
3. 然后找到 http.conf 文件中的如下內容
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "F:ampApache2.2htdocs">
將 Diectory 中的路徑改成你新設的文件根目錄,比如:
<Directory "C:/htdocs">
4. 保存配置文件http.conf 。
5. 修改了配置文件以后,應重新啟動 Apache Service。(Apache HTTP Server 2.2 --> --> Restart)
修改了文件根目錄之后,你就可以將你的網頁存放在新設的目錄下了