当前位置: 移动技术网 > 网络运营>服务器>Windows > Apache 文件根目录设置修改方法 (Document Root)

Apache 文件根目录设置修改方法 (Document Root)

2019年04月19日  | 移动技术网网络运营  | 我要评论
在网上查找到的关于修改apache服务器根目录的资料,对比学习,再此记录
在安装 apache 时,系统会给定一个缺省的文件根目录。
如果你觉得将网页存在这个缺省目录不方便,觉得应该另外设个目录作为 apache 文件根目录,你可以修改 apache 的配置文件 httpd.conf 里有关文件根目录的设置。
假设apache http server 的缺省文件根目录 (documentroot) 是:
documentroot "c:\program files\apache software foundation\apache2.2\htdocs"
修改 apache 文件根目录 (documentroot) 的操作如下:

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)
修改了文件根目录之后,你就可以将你的网页存放在新设的目录下了。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网