win10 Apache虚拟主机localhost无法访问,如何排查并解决配置问题?

更新于
2026-09-24 14:48:12
0阅读来源:SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计306个文字,预计阅读时间需要2分钟。

win10 Apache虚拟主机localhost无法访问,如何排查并解决配置问题?

Win10系统配置虚拟主机+1.使用记事本或Sublime Text打开httpd.conf文件+Ctrl+F+搜索httpd-vhosts.conf+将

win10系统配置虚拟主机

1.用记事本或Sublime Text打开httpd.conf

ctrl + f 搜索httpd-vhosts.conf


#Include conf/extra/httpd-vhosts.conf
的#号去掉保存

2.打开extra/httpd-vhosts.conf

添加如下内容:

<VirtualHost *:80> ServerAdmin webmaster@youremail.com DocumentRoot "E:/your_web_root" ServerName your.web.com ErrorLog "logs/your_web_error.log" CustomLog "logs/your_web_access.log" common </VirtualHost>

3.本地测试的话,还需要在hosts文件中配置一个域名解析条目,在C:/windows/system32/drivers/etc/目录下找到hosts文件

4.完成以上步骤后,重启Apahce就可以了

重点来了

这时虚拟主机的域名www.web.com可以正常访问,但是localhost就不能访问了。

阅读全文

本文共计306个文字,预计阅读时间需要2分钟。

win10 Apache虚拟主机localhost无法访问,如何排查并解决配置问题?

Win10系统配置虚拟主机+1.使用记事本或Sublime Text打开httpd.conf文件+Ctrl+F+搜索httpd-vhosts.conf+将

win10系统配置虚拟主机

1.用记事本或Sublime Text打开httpd.conf

ctrl + f 搜索httpd-vhosts.conf


#Include conf/extra/httpd-vhosts.conf
的#号去掉保存

2.打开extra/httpd-vhosts.conf

添加如下内容:

<VirtualHost *:80> ServerAdmin webmaster@youremail.com DocumentRoot "E:/your_web_root" ServerName your.web.com ErrorLog "logs/your_web_error.log" CustomLog "logs/your_web_access.log" common </VirtualHost>

3.本地测试的话,还需要在hosts文件中配置一个域名解析条目,在C:/windows/system32/drivers/etc/目录下找到hosts文件

4.完成以上步骤后,重启Apahce就可以了

重点来了

这时虚拟主机的域名www.web.com可以正常访问,但是localhost就不能访问了。

阅读全文