【问题标题】:Vagrant localhost issue流浪本地主机问题
【发布时间】:2015-06-11 14:28:17
【问题描述】:

我在我的 Ubuntu 15 上安装了 Vagrant 和 VM,添加了一个盒子并没有问题地做了一个 vagrant。但是当我对浏览器说 127.0.0.1:8080 时,我无法连接到我的项目。我在 vagrant 上做错了什么?

这是我的 Vagrantfile:

Vagrant.configure(2) do |config|
  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://10.0.1.254:3128/"
    config.proxy.https    = "http://10.0.1.254:3128/"
    config.proxy.no_proxy = "localhost,127.0.0.1,.teste.com"
  end
  config.vm.box = "hashicorp/precise32"
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

【问题讨论】:

  • Apache 安装了吗?抛出的错误是什么?

标签: ubuntu localhost vagrant


【解决方案1】:

您可以通过使用专用网络而不是端口转发来回避这个问题。注释掉 Vagrantfile 中的“forwarded_port”行并添加以下内容:

config.vm.network "private_network", ip:"192.168.50.4"

只要您使用的 IP 地址尚未在您的网络上使用,这将起作用。上面那个应该没问题。

这还允许您通过一个不错的 url 访问您的网站,方法是将以下行添加到托管 vagrant 的机器上的 /etc/hosts 文件中:

192.168.50.4    mysite.dev

【讨论】:

    猜你喜欢
    • 2016-12-08
    • 2020-08-05
    • 1970-01-01
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多