apache虚拟主机的配置步骤:
一、启用httpd-vhosts.conf文件
用conf/httpd.conf找到
httpd-vhosts.conf,去掉前面注释“#”;
二、配置httpd-vhosts.conf
配置方法一:一个IP绑定多个域名的方法
<VirtualHost *:80>
DocumentRoot "D:/a_com"
ServerName www.baidu.com
DirectoryIndex index.html index.php
<Directory />
Option FollowSymLinks
#不容许修改别人修改咱们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
如再绑定别外域名,再添加:
<VirtualHost *:80>
DocumentRoot "D:/b_com"
ServerName www.sina.com
DirectoryIndex index.html index.php
<Directory />
Option FollowSymLinks
#不容许修改别人修改咱们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.2:80>
DocumentRoot "D:/a_com"
DirectoryIndex index.html index.php
<Directory />
Option FollowSymLinks
#不容许修改别人修改咱们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
三、修改hosts文件(若是是公网IP,则须要到域名管理里面去作配置)
在最后一行添加IP与域名的对应
127.0.0.2 www.XXX.com
四、重启apache,访问测试成功