Vagrant / Mac端口转发无效

时间:2015-08-14 02:09:27

标签: apache vagrant portforwarding vagrantfile

Mac OS在这里。我无法让Vagrant端口转发从我的来宾虚拟机到我的主机。我按照Networking/Port-Forwarding tutorial逐字记录。

这是我的项目:

testvm/
    Vagrantfile
    bootstrap.sh

bootstrap.sh安装Apache httpd:

#!/usr/bin/env bash

apt-get update
apt-get install -y apache2
if ! [ -L /var/www ]; then
    rm -rf /var/www
    ln -fs /vagrant /var/www
fi

我的Vagrantfile

Vagrant.configure(2) do |config|
    config.vm.provision :shell, path: "bootstrap.sh"
    config.vm.network :forwarded_port, guest: 80, host: 4567
    config.vm.box = "hashicorp/precise32"
end

当我vagrant up我没有收到任何错误,但是当我打开网络浏览器并转到http://127.0.0.1:4567并且我得到一个Safari“无法打开网页”时, “ Hey it works!” - 您通常使用httpd获得的类型页面。

关于这里出了什么问题的任何想法?

1 个答案:

答案 0 :(得分:1)

您是否已检查VM上的防火墙已禁用/允许访问端口80?

VM内部按预期使用

$ curl http://localhost