如何从实际的计算机访问虚拟机上的django开发服务器 [英] how to access django development server on virtual machine from actual computer

查看:261
本文介绍了如何从实际的计算机访问虚拟机上的django开发服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有我的实际的笔记本电脑安装了vmware播放器。我正在运行lubuntu作为一个虚拟机,我在虚拟机上安装了django,并且正在测试我的应用程序,所以我做了python manage.py runserver,我可以通过访问我的虚拟机127.0.0.1:8000访问该应用程序,但是如果我从实际的电脑(不是虚拟机)去127.0.0.1:8000,它说'chrome无法连接到127.0.0.1:8000'..任何想法如何解决?

解决方案

我能够得到@Kerberos的答案。 (没有足够的评论点,所以我把它添加为一个单独的答案)。



我在VMWare的客户操作系统中运行Ubuntu 12.04 LTS。主机笔记本电脑正在运行Windows 8。



如Kerberos所述,在VMWare中,转到 Player ==>管理==>虚拟机设置...



在硬件选项卡上,选择网络适配器然后选择 Bridged的单选按钮:直接连接到物理网络。选择确定



在虚拟机中,网络连接信息现在应该具有主机操作系统互联网的相同IP地址连接。在我的情况下:192.168.1.141(你的不同)。



在虚拟机中,使用 python manage runserver启动Django 192.168.1.141:8000



使用此方法,我可以从虚拟机访问虚拟机中的VM服务器,从主机和来自同一个192.168.1.xxx网络上的其他系统。


Okay so I have my actual laptop which has vmware player installed. I am running lubuntu as a virtual machine and I installed django on the virtual machine and am testing my app so I did python manage.py runserver and I can access the app by visiting 127.0.0.1:8000 from my VM, however, If I go to 127.0.0.1:8000 from the actual computer (not the VM), it says 'chrome could not connect to 127.0.0.1:8000'.. Any idea how to fix it?

解决方案

I was able to get @Kerberos answer to work. (not enough points to comment so I'm adding it as a seperate answer).

I am running Ubuntu 12.04 LTS in a guest OS in VMWare. The host laptop is running Windows 8.

As mentioned by Kerberos, in VMWare, go to Player ==> Manage ==> Virtual Machine Settings...

On the Hardware tab, select Network Adaptor, then select the radio button for Bridged: Connect directly to the physical network. Select OK

In the VM, the network connection information should now have the same IP address of the host OS internet connection. In my case: 192.168.1.141 (yours will vary).

In the VM, start Django using python manage runserver 192.168.1.141:8000

Using this method, I am able to access the webserver running in the VM at this IP address from within the VM, from host machine, and from other systems on the same 192.168.1.xxx network.

这篇关于如何从实际的计算机访问虚拟机上的django开发服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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