1.打开虚拟主机配置,打开D:\phpStudy\Apache\conf下的 httpd.conf文件去掉#Include conf/extra/httpd-vhosts.conf前面的#保存即可。在D:\WWW目录下建立web应用例如 classmath。

2.打开D:\phpStudy\Apache\conf\extra下的httpd-vhosts.conf文件,复制以下代码在文件最后粘贴即可。
<VirtualHost *:80>
DocumentRoot "D:\WWW\classmath"
ServerName web.classmath.com
</VirtualHost>
<Directory "D:\WWW\classmath">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
打开C:\Windows\System32\drivers\etc下的hosts文件添加
127.0.0.1 web.classmath.com
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "D:\WWW"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>