在主机上的vagrant virtualbox中访问django服务器?

时间:2016-03-16 19:25:36

标签: vagrant virtualbox portforwarding vagrant-windows

我使用windows和putty来ssh到vagrant virtualbox。我无法使用http://localhost:9991访问在vagrant virtualbox中运行的django服务器 我也禁用了我的防火墙 这是我的流浪档案:

VAGRANTFILE_API_VERSION = "2"

def command?(name)
  `which #{name}`
  $?.success?
end

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  # For LXC. VirtualBox hosts use a different box, described below.
  config.vm.box = "fgrehm/trusty64-lxc"

  # The Zulip development environment runs on 9991 on the guest.
  config.vm.network "forwarded_port", guest: 9991, host: 9991, host_ip: "127.0.0.1"

  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.synced_folder ".", "/srv/zulip"

  # Specify LXC provider before VirtualBox provider so it's preferred.
  config.vm.provider "lxc" do |lxc|
    if command? "lxc-ls"
      LXC_VERSION = `lxc-ls --version`.strip unless defined? LXC_VERSION
      if LXC_VERSION >= "1.1.0"
        # Allow start without AppArmor, otherwise Box will not Start on Ubuntu 14.10
        # see https://github.com/fgrehm/vagrant-lxc/issues/333
        lxc.customize 'aa_allow_incomplete', 1
      end
    end
  end

  config.vm.provider "virtualbox" do |vb, override|
    override.vm.box = "ubuntu/trusty64"
    # 2GiB seemed reasonable here. The VM OOMs with only 1024MiB.
    vb.memory = 2048
  end

$provision_script = <<SCRIPT
set -x
set -e
sudo apt-get update
sudo apt-get install -y python-pbs
/usr/bin/python /srv/zulip/provision.py
SCRIPT

  config.vm.provision "shell",
    # We want provision.py to be run with the permissions of the vagrant user.
    privileged: false,
    inline: $provision_script
end

如何从主机(Windows)访问服务器?

1 个答案:

答案 0 :(得分:0)

我建议(在客人身上):

sudo netstat -lnutp 

并查看哪些端口处于打开状态,以及拥有它们的进程。如果缺少您想要的那个,请确保已启动负责该服务的服务,或自行启动。从你的Vagrant文​​件的外观来看,这将是“Zulip开发环境”。