首先找到在apache的目录下的文件:/apache/conf/httpd.conf
找到 #Include "conf/extra/httpd-vhosts.conf" 将'#'去掉,即开启虚拟主机配置
然后找到目录下的虚拟主机配置文件:/apache/conf/extra/httpd-vhosts.conf
找到#NameVirtualHost *:80 开启监听80端口(可设置8080或者其他端口)
下面为设置localhost与虚拟主机test.com配置
<VirtualHost *:80>
DocumentRoot "D:/www/"
ServerName localhost
<Directory />
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/www/test"
ServerName test.com
<Directory />
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>