1、先下载wampserver软件安装好,我这里是安装到E盘,目录在E:\wamp\www。软件可以百度搜索自己下载一个。
2、打开文件E:\wamp\bin\apache\apache2.4.9\conf\httpd.conf;
然后找到下面这个模块#Include conf/extra/httpd-vhosts.conf,去掉前面#,这样就可以开启httpd-vhosts虚拟主机模块。
3、打开路径文件E:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf。把要解析的域名配置上去,还有域名绑定的目录。参考如下
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/wamp/www"
ServerName 127.0.0.1
ServerAlias localhost
<Directory "E:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/wamp/www/aaa"
ServerName www.aaa.com
<Directory "E:/wamp/www/aaa">
Options Indexes FollowSymLinks
AllowOverride All 纯轮
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/wamp/www/bbb"
ServerName www.bbb.com
<Directory "E:/wamp/www/bbb">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
<胡裤芦/Directory>
</VirtualHost>
4、然后打开文件C:\Windows\System32\drivers\etc\hosts,解析域名
127.0.0.1 www.aaa.com
127.0.0.1 www.bbb.com
最后重启服务器就可以在浏览器访问www.aaa.com和裤带www.bbb.com了。