windows下apache的虚拟主机virtualhost配置

来源:互联网 发布:矩阵的叉积怎么算的 编辑:程序博客网 时间:2024/04/28 00:23

转载请注明出处 : )

http://blog.csdn.net/shruby/article/details/41593859


目的:使一个或多个域名指向默认根目录htdoc一个或多个子目录。

步骤

1,、修改windows的hosts文件,位置在C:\Windows\System32\drivers\etc目录下

讲要改成的域名添加在尾行,格式如下:

127.0.0.1     xxxxx.xidian.edu.cn

2、修改apache配置文件httpd-vhosts.conf,我的这个配置文件位置在D:\Apache2.2\conf\extra目录下

修改成如下:(第一个是原来的根目录设置,第二个写上你的)

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot D:/Apache2.2/htdocs/
</VirtualHost>

<VirtualHost *:80>
ServerName
xxxxx.xidian.edu.cn
ServerAlias testhost
DocumentRoot D:/Apache2.2/htdocs/
xxxxx.xidian.edu.cn/
</VirtualHost>

3、修改apache配置文件httpd.conf,位置在D:\Apache2.2\conf目录下

a、将 LoadModule vhost_alias_module modules/mod_vhost_alias.so 前的#去掉

b、将 Include conf/extra/httpd-vhosts.conf 前的#去掉

c、在第200行左右有一个根目录设置,找到这句话# This should be changed to whatever you setDocumentRoot to.下面有一个原来根目录的设置保留他原来的,在下面添加一个你要添加的路径,格式如下同原来的一样。路径写上你虚拟主机的路径

<Directory "D:/Apache2.2/htdocs/xxxxx.xidian.edu.cn">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

4、保存文件,重启apache,浏览器访问xxxxx.xidian.edu.cn,就会访问你虚拟主机,htdocs下的xxxxx.xidian.edu.cn文件夹


可能有不当之处,请留言指正,帮助更多的人,谢谢。




4、

0 0
原创粉丝点击