修改 Apache 文件根目录 (DocumentRoot)

如何设置 Apache HTTP Server 的文件根目录(DocumentRoot) 。

在安装 Apache 时,系统会给定一个缺省的文件根目录。

如果你觉得将网页存在这个缺省目录不方便,觉得应该另外设个目录作为 Apache 文件根目录,你可以修改 Apache 的配置文件 httpd.conf 里有关文件根目录的设置。

Apache HTTP Server 的缺省文件根目录 (DocumentRoot) 是:

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
修改 Apache 文件根目录 (DocumentRoot) 的操作如下:

. 保存配置文件http.conf 。> All。

1. 为避免修改失误,请先备份你的 Apache 配置文件 httpd.conf,该配置文件的路径是:

C:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf
2. 打开 http.conf 文件,找到 DocumentRoot 为开头的那一行,将

DocumentRoot  "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
改成新的 DocumentRoot 路径,比如你新的路径为 C:/htdocs,就改成

DocumentRoot "C:/htdocs"
3. 然后找到 http.conf 文件中的如下内容

# This should be changed to whatever you set DocumentRoot to.#
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
将 Diectory 中的路径改成你新设的文件根目录,比如:

<Directory  "C:/htdocs">
4. 保存配置文件http.conf 。

5. 修 改了配置文件以后,应重新启 动 Apache Service。(Start --> All Programs --> Apache HTTP Server 2.2 --> Monitor Apache Servers --> Restart)

修改了文件根目录之后,你就可以将你的网页存放在新设的目录下了。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值