打开注释 NameVirtualHost *:80
添加以下内容:
<virtualhost *:80>
documentroot "D:\zq\myself\01"
servername book
## errorlog @rel_logfiledir@/dummy-host2.example.com-error_log
## customlog @rel_logfiledir@/dummy-host2.example.com-access_log common
</virtualhost>
<virtualhost *:80>
documentroot "D:\zq\thinkphp\Examples"
servername demo
## errorlog @rel_logfiledir@/dummy-host2.example.com-error_log
## customlog @rel_logfiledir@/dummy-host2.example.com-access_log common
</virtualhost>
<directory "D:\zq\myself\01">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</directory>
<directory "D:\zq\thinkphp\Examples">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</directory>
修改后,保存httpd-vhosts.conf文件,重启Apache。
第二步:编辑此文件:
C:\WINDOWS\system32\drivers\etc\hosts
在后面添加:
127.0.0.1 book
127.0.0.1 demo
然后保存。然后通过访问 http://book即可访问新虚拟站点了。