virtualhost – 无法在我的Linux服务器上运行主机文件

前端之家收集整理的这篇文章主要介绍了virtualhost – 无法在我的Linux服务器上运行主机文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在VirtualBox上运行了Ubuntu 11.10,并且我已经设置了一个虚拟命名服务器.
我可以从 Windows 7访问此站点,但我无法从Ubuntu访问该站点.

我的HOSTS文件位于/ etc /文件夹中,如下所示:

@H_404_5@127.0.0.1 localhost 127.0.1.1 ubuntu-VirtualBox 192.168.0.97 mysite.com

但每当我尝试从服务器访问mysite.com时,我都会被重定向到一个网站,说这个域名是出售的.

什么原因导致主机文件无法正常工作?

更新

这是我的/etc/nsswitch.conf

@H_404_5@# /etc/nsswitch.conf # # Example configuration of GNU Name Service Switch functionality. # If you have the `glibc-doc-reference' and `info' packages installed,try: # `info libc "Name Service Switch"' for information about this file. passwd: compat group: compat shadow: compat #hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 hosts: files dns networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: nis

解决方法

首先,检查nsswitch.conf是否正确: @H_404_5@$grep hosts /etc/nsswitch.conf hosts: files dns

确保它显示“files dns”,否则在询问DNS之前它不会查看您的hosts文件.

如果在nsswitch中它是正确的,我之前看到一个看不见的角色以某种方式进入我的主机文件,导致它看起来完全正常,但是这个看不见的角色使它不起作用.
因此,尝试删除该行,然后再次创建它 – 手动,不要粘贴.

接下来你可以尝试通过ping来测试它的内容

@H_404_5@$ping mysite.com PING mysite.com (192.168.0.97) 56(84) bytes of data.

如果您在那里看到正确的IP地址,它确实可以正确解析,并且您的浏览器是导致问题的浏览器.不要使用host,dig或nslookup,它们会忽略/ etc / hosts!使用ping可以解析IP地址,因为大多数应用程序都会看到它.

原文链接:https://www.f2er.com/linux/396348.html

猜你在找的Linux相关文章