1.打开虚拟主机配置,打开D:\phpStudy\Apache\conf下的 httpd.conf文件去掉#Include conf/extra/httpd-vhosts.conf前面的#保存即可。
![](https://img.haomeiwen.com/i1342398/0398a53724e59955.jpg)
2.同时查看 httpd.conf中的权限是否允许
DocumentRoot"D:\phpStudy\WWW"
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
![](https://img.haomeiwen.com/i1342398/73ccbfc29cf09575.jpg)
然后在D:\ phpStudy \WWW目录下建立web应用例如 test。
3.打开D:\phpStudy\Apache\conf\extra下的httpd-vhosts.conf文件
DocumentRoot D:\phpStudy\WWW\test
ServerNametest.com
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
4. win + r 输入 C:\Windows\System32\drivers\etc 打开hosts文件添加
127.0.0.1 test.com
此时在浏览器上输入 test.com就可以直接访问网站根目录下得test了
网友评论