Apache配置虚拟主机后,不能访问localhost的问题

【前言】

      Apache配置虚拟主机后,不能访问localhost,只能通过设置好虚拟域名访问。

      可以通过把localhost变成虚拟域名。

      参考文件:http://570109268.iteye.com/blog/2414410

【主体】

(1)设置虚拟域名

先在httpd-vhosts.conf设置好虚拟域名localhost

<VirtualHost _default_:80>
   DocumentRoot "C:\phpStudy\" 
   ServerName localhost       
</VirtualHost>

Apache配置虚拟主机后,不能访问localhost的问题

(2)把httpd.conf文件的ServerName localhost:80 那行注释掉

扫描二维码关注公众号,回复: 212687 查看本文章

Apache配置虚拟主机后,不能访问localhost的问题

(3)别忘了查看hosts文件里是否绑定 localhost指向127.0.0.1,一般情况下会存在

Apache配置虚拟主机后,不能访问localhost的问题

(4)重要的是第二点,要注释掉httpd.conf文件的ServerName localhost:80

.

猜你喜欢

转载自570109268.iteye.com/blog/2414420