在wamp下利用httpd-vhosts.conf设置multiple domain

Posted August 7th, 2009. Filed under Apache

在网路上找到很多文字来教大家设置multiple domain, 很多都是在httpd.conf里面实现的. 但最近的开发一直是利用httpd-vhosts.conf, 却一直郁闷在无法设置multiple domain的问题上.
问过X老师之后, 几分钟搞定=.=b, 这家伙一眼就指出了我滴错误…万恶的粗心大意啊.

所以利用httpd-vhosts.conf其实没有想象中那么纠结.

1)httpd-vhosts.conf文件的设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<Directory D:/Wamp2/www>
Order Deny,Allow
Allow from all
Options All
AllowOverride All
</Directory>
 
<VirtualHost *:80>
    ServerAdmin cora@cora.subsite1.com
    DocumentRoot "D:/Wamp2/www/sub1"
    ServerName cora.subsite1.com
</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin cora@cora.subsite1.com
    DocumentRoot "D:/Wamp2/www/sub2"
    ServerName cora.subsite2.com
</VirtualHost>

2)在apache的httpd.conf设置

在httpd.conf里面, 一定要uncomment

1
2
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

其他都不需要修改, 尤其是documentroot, 如果是在用wamp, 就默认为[FilePath]/www

3)hosts老师

另外, 在 hosts 里面要记得加入子域名的指向IP

1
2
127.0.0.1       cora.subsite1.com
127.0.0.1       cora.subsite2.com

4)什么是conf文件呢?

熊熊说, conf文件就是xml. 其实也不完全是, xml是conf文件的一种流行的格式.

conf常常用ASCII编码, 也有少部分用UTF-8的. 怪不得conf文件默认打开的程序总是notepad涅.

WIKI上时绛紫解释的: http://en.wikipedia.org/wiki/Configuration_file

++好孩子珊瑚++

  • Share/Bookmark