1, apach配置文件开启虚拟主机服务(C:\AppServ\Apache2.2\conf\httpd.conf)大概561行的位置
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2,在C:\AppServ\Apache2.2\conf\extra\httpd-vhosts.conf这个配置文件里添加虚拟主机目录
<VirtualHost *:80>
DocumentRoot "C:/AppServ/www/qiantai/"
ServerName www.ruidie.com
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/AppServ/www/qiantaidede/"
ServerName www.qiantaitest.com
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/AppServ/www/oularapp_mh/"
ServerName www.mhtest.com
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
</VirtualHost>
<Directory "C:/AppServ/www/oularapp_mh/">
Options FollowSymLinks ExecCGI Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/AppServ/www/code/"
ServerName www.oularapptest.com
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/AppServ/www/ecmall/"
ServerName www.ecmalltest.com
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/AppServ/www/"
ServerName localhost
ErrorLog "logs/dummy-host.x-error.log"
CustomLog "logs/dummy-host.x-access.log" common
</VirtualHost>
3,C:\WINDOWS\system32\drivers\etc\hosts文件里添加
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 www.qiantaitest.com
127.0.0.1 www.mhtest.com
127.0.0.1 www.oularapptest.com
127.0.0.1 www.ecmalltest.com
重启apach服务(cmd命令 services.msc可以打开服务或者右击我的电脑-->管理-->服务和应用程序)