解决打开 Wamp主页面在VirtualHost一项出现以下错误: ServerName localhost:8080 is not defined into hosts file.

文章目录


问题

打开 Wamp主页面在VirtualHost一项出现以下错误:
ServerName localhost:8080 is not defined into hosts file.

最后一项
可以看到最后一项提示hosts file error并且提示Error(s) see below

网上未找到其他有关教程,尝试更改Apache 下的“httpd-vhosts.conf”文件
1.左单击状态栏wampserver图标
2.点击Apache栏
3.在“文件&文档”一栏找到“httpd-vhosts.conf”单击打开
4.如下图所示
在这里插入图片描述
5.尝试将ServerName localhost更改为 ServerName localhost:8080
在这里插入图片描述
6.保存回到主页刷新后依然提示出错
在这里插入图片描述
错误变为syntax error
The ServerName localhost:8080:8080 has syntax error in file D:/wamp64/bin/apache/apache2.4.51/conf/extra/httpd-vhosts.conf
意为语法错误

7.撤回更改
在这里插入图片描述

在这里插入图片描述
错误恢复到原来的样子

8.尝试从状态栏直接启动虚拟主机localhost

依然左键wampserver图标,点击 “Your VirtualHosts”,选择提示出错的“localhost:8080”打开
9.弹出弹窗
在这里插入图片描述
提示“In the httpd-vhosts.conf file:

‘localhost:8080’ ServerName

is not defined into ‘C:/WINDOWS/system32/drivers/etc/hosts’ file.”

10.因此找到’C:/WINDOWS/system32/drivers/etc/hosts’ file.”文件
选择任意编辑器打开,我这里用的是vscode
在这里插入图片描述
打开之后如上图
11.将第二个localhost更改为localhost:8080
在这里插入图片描述

12.保存时出现提示
在这里插入图片描述
13.选择以管理员身份重试,选择是
14.此时在回到主页面刷新
在这里插入图片描述
16.报错解决


总结

在状态栏内点击报错的虚拟主机打开,根据提示的路径找到hosts文件对其进行更改即可解决“ServerName localhost:8080 is not defined into hosts file.”报错。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值