从VirtualBox虚拟机寻址localhost [英] Addressing localhost from a VirtualBox virtual machine

查看:258
本文介绍了从VirtualBox虚拟机寻址localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本地测试/开发服务器(当然是HTTP),正在监听端口8000.

I have a local test/development server (HTTP, of course), listening to port 8000.

我正在Linux上工作,因此要在Internet Explorer 6、7、8等上测试该页面.我还需要查看Windows环境下Firefox上的外观(例如,字体是不同的).

I'm working on Linux, so to test the page on Internet Explorer 6, 7, 8, etc. I run a virtual machine using VirtualBox; I also need to see how it look on Firefox in a windows environment (fonts for instance are different).

在我的真实计算机上,我仅使用URL http://localhost:8000打开网站,如何从虚拟机访问该本地主机?

In my real machine, I open the website simply using the URL http://localhost:8000, how do I address this localhost from the virtual machine?

现在,我的解决方法是使用IP地址.还有更好的主意吗?

Right now my workaround is to use the IP address. Any better ideas?

推荐答案

Google搜索将其转为: http://data.agaric.com/localhost-from-virtualbox-xp-install-ubuntu

Googling turned this up: http://data.agaric.com/localhost-from-virtualbox-xp-install-ubuntu

它建议使用IP:http://10.0.2.2,并且对我有用.

It suggests using IP: http://10.0.2.2, and it worked for me.

因此,我编辑了主机文件C:\windows\system32\drivers\etc\hosts,并添加了以下条目:

So, I edited the hosts file, C:\windows\system32\drivers\etc\hosts, and added this entry:

10.0.2.2   outer

如果要在IE8上进行测试,请记住将http://放在地址栏中.仅直接放置ip无效.

If you're testing on IE8, remember to put http:// in the address bar. Just putting the ip directly will not work.

例如:

http://10.0.2.2:3000/

这篇关于从VirtualBox虚拟机寻址localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆