apache建立多个站点[不同域名]

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#


<VirtualHost *:80>
 ServerName bbs.xxx.com   #域名
 DocumentRoot "F:/website/bbs"   #该域名对应的目录地址 
<Directory "F:/website/bbs">   #该节点是配置权限、默认首页啊等等东东。
 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex  index.php
 AllowOverride None
 Order Deny,Allow
 Allow from all   
</Directory>
</VirtualHost>


<VirtualHost *:80>
 ServerName blog.xxx.com
 DocumentRoot "D:/PHPSite/wordpress"
<Directory "D:/PHPSite/wordpress">
 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex  index.php
 AllowOverride None
 Order Deny,Allow
 Allow from all
</Directory>
</VirtualHost>

重启apache。
如果不行的话,看你的httpd.conf是否启用了vhost
打开httpd.conf,找到
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
看是否启用,即去掉Include conf/extra/httpd-vhosts.conf前的#
重启apache,爽去吧。

文章来源:http://www.yibin001.com/Archives/6066.aspx

注:这个方法,在网上很多地方都出现过,或多或少有些出入,但本人一次也没有调试成功,感觉有点麻烦,还要修改hosts文件,不如直接IP方法来的直接方便
似乎也要修改hosts文件,还是算了,麻烦死了。

当你要调试的站点多了的话,恐怕记不住那么多IP吧,现在都记乱了,还是域名比较好记些。

300*300
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00531 秒