修改 Apache 根目录

在安装 Apache 时,会默认文件根目录为安装目录下的htdocs。可以修改 Apache 的配置文件 httpd.conf 里有关文件根目录的设置修改根目录。

修改 Apache 文件根目录的操作如下:

1. 备份 Apache 配置文件 httpd.conf,该配置文件的路径是:

%install%\conf\httpd.conf

2. 打开 http.conf 文件,找到 DocumentRoot 为开头的那一行,将DocumentRoot改成新的 DocumentRoot 路径

比如想改到 D:\website,就改成

DocumentRoot D:/website”

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 “D:/website”>

5. 重新启动 Apache

修改了文件根目录完成

////////////////////////////////其他虚拟目录创建

环境:appserv构架的,端口:90

测试页面:http://127.0.0.1:90

目的:将f盘下的www文件夹作为虚拟目录!

找到
C:\\AppServ\\Apache2.2\\conf 里面的httpd.conf文件,(修改前备份下)用记事本打开,找到:

Alias /icons/ “C:/AppServ/Apache2.2/icons/”

<Directory “C:/AppServ/Apache2.2/icons”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

修改如下:

Alias /icons/ “C:/AppServ/Apache2.2/icons/”
Alias /life/ “f:/www/”

<Directory “C:/AppServ/Apache2.2/icons”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory “f:/www”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

重新启动Apache
测试访问:

http://127.0.0.1:90/life/页面名称

收藏于 2010-06-13


关注公众号,了解更多it技术(it问答网

发表评论

电子邮件地址不会被公开。