当我更改 VirtualHost 中的服务器名称时,Apache (xampp) 不起作用
问题:
一切正常,直到我将“dev”的名称更改为其他名称,即“devo”。 错误日志显示“无法解析主机名”。 “开发”站点是使用 PHP Symfony 完成的。
我尝试做的事情:
- 之前有人已经设置过它,所以我删除了所有内容,然后再次复制了该项目,重新安装了 XAMPP,重写了 vhosts 文件,但问题仍然存在。
- 我检查了我的 Firefox 和 IE 设置,LAN 设置中没有特殊规则。
- 我尝试清除浏览器缓存。
我的问题是:更改主机名怎么会把一切搞砸?
我的 httpd-vhosts.conf 的内容:
NameVirtualHost 127.0.0.1:80
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
</VirtualHost>
<VirtualHost dev:80>
ServerName dev
DocumentRoot "C:\workspace\trunk\web"
</VirtualHost>
The issue:
Everything works fine all until I change the name of 'dev' into anything else, i.e.'devo'.
Error logs say s'could not resolve host name'. The 'dev' site is done with PHP Symfony.
What I tried doing:
- Someone before has setup it up, so I removed everything, and copied over the project again, reinstalled XAMPP, rewrote the vhosts file, but the issue remained.
- I checked my Firefox and IE settings and there's no special rules in LAN settings.
- I tried clearing my browsers cache.
My Question is: How can a change of hostname screw everything up?
Contents of my httpd-vhosts.conf:
NameVirtualHost 127.0.0.1:80
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
</VirtualHost>
<VirtualHost dev:80>
ServerName dev
DocumentRoot "C:\workspace\trunk\web"
</VirtualHost>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与这个问题大致相同。
但对于您来说,它是
%WINDIR%\System32\drivers\etc\hosts
。我猜你的机器名称是
dev
,因此可以解析。任何其他主机名(或就此而言的ServerName
)都需要显示在hosts
文件中,以便可以解析为 IP 地址。About the same as this question.
Although for you, it's
%WINDIR%\System32\drivers\etc\hosts
.I guess your machine's name is
dev
and can hence be resolved. Any other hostname (orServerName
for that matter) needs to show up in thehosts
file so it can be resolved to an IP address.名称解析怎么样(检查您的主机)?你的电脑 ping devo 到本地主机吗?
无论如何,您还可以使用 ServerAlias 为特定安装指定多个名称。
What about names resolution (check your hosts)? Does your pc ping devo to localhost?
Anyway, you can also use ServerAlias to specify more than one name for a specific installation.