1、点击桌面右下角的WAMP图标,依次打开Apache--->httpd.conf
WAMP配置虚拟主机

2、打开httpd.conf配置文件,ctrl+f进行搜索,输入#Include conf/extra/httpd-vhosts.conf ,然后去掉前面的#,保存退出。如下:

# Server-pool management (MPM specific)
# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf  //去掉前面的'#'号

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

3、依次打开conf/extra/httpd-vhosts.conf文件,默认的WWW建议不要动,直接增加你需要的虚拟主机就可以了,我这边是配置的tools.lianst.com,如下:


    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common


# 以下就是我新增的

    ServerAdmin webmaster@lianst.com     //配置服务器管理员邮箱
    DocumentRoot "D:/wwwroot/tools.lianst.com     //服务器根目录
    ServerName tools.lianst.com      //服务器名称,也就是域名
    ErrorLog "tools.lianst.com-error.log"     //错误日志
    CustomLog "tools.lianst.com-access.log" common
      //此区域不配置的话apache会报没有权限访问
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all


4、进入到C:\Windows\System32\drivers\etc,打开(右键管理员)host文件,在最下面一行添加:

127.0.0.1       localhost
127.0.0.1       localhost
127.0.0.1       tools.lianst.com   //添加这一行

5、最后重启一下apahce,然后使用tools.lianst.com就可以访问了。
WAMP配置虚拟主机