1.事先建立两个域名站点
分别建立web1和web2站点,分别建立主页面web1.html和web2.html;
2.在httpd.conf文件中启用httpd-vhosts.conf
去掉#,即
#Virtual hosts (虚拟主机)Include conf/extra/httpd-vhosts.conf
3.设置http-vhosts.conf文件(路径:X:/ApacheX.X/conf/extra/http-vhosts.conf)
添加以下内容:
#配置虚拟主机<VirtualHost*:80>DocumentRoot "d:/web1"ServerName#配置欢迎首页面DirectoryIndexweb1.htmlindex.html index.htm index.php<Directory />Options FollowSymLinks#不许别人修改网站页面AllowOverride None#设置访问权限Order allow,denyAllow from all</Directory></VirtualHost>#配置虚拟主机<VirtualHost*:80>DocumentRoot "d:/web2"ServerName#配置欢迎首页面DirectoryIndexweb2.htmlindex.html index.htm index.php<Directory />Options FollowSymLinks#不许别人修改网站页面AllowOverride None#设置访问权限Order allow,denyAllow from all</Directory></VirtualHost>
4.在hosts文件中添加我们的ip和主机映射关系(路径:c:/windows/system32/drivers/etc/hosts)
在 127.0.0.1 localhost下添加如下地址
127.0.0.1 127.0.0.1
配置完成。
现在就可以在同一个ip下访问两个域名(和)站点了。