【问题标题】:unable to connect to localhost:8080 with Vagrant and Ubuntu无法使用 Vagrant 和 Ubuntu 连接到 localhost:8080
【发布时间】:2014-09-18 22:28:39
【问题描述】:

我尝试在 mac os 10.9.4 上安装 Vagrant 和 Ubuntu,以按照@fideloper 的以下重要说明制作本地开发服务器:Vagrant and Apache

Vagrantfile 包含:

config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder ".", "/var/www/html"

evreything 在此过程中运行良好:安装了 Vagrant 和 virtualbox,在客户机上安装了 Apache。

来自this answer,我试过了:

  • 在客户机上,curl 'http://localhost:80' 返回一个带有文件列表的 html
  • 在主机上,curl -v 'http://localhost:8080' 返回 同一页。

但浏览器在 localhost:8080 显示 this webpage is not available

为什么浏览器不显示 localhost:8080?

【问题讨论】:

    标签: apache ubuntu vagrant


    【解决方案1】:

    设置:

    config.vm.synced_folder ".", "/var/www/html"
    

    将用您主机的"." 目录(共享目录)中的任何内容覆盖服务器的/var/www/html 目录中的任何内容。

    /var/www/html/index.html 不再有 Apache 的默认 index.html 文件,因为您在 Vagrant synced_folder 设置中将共享目录安装在该位置。

    根据您的说法,它工作正常,您可以开始将自己的 .html 文件添加到您的共享文件夹中,然后继续!您的共享目录中没有 .html 文件可提供服务,因此 Apache 回退到在那里显示文件的索引。

    【讨论】:

    • 一切正常,除了浏览器显示this webpage is not available 并且不显示任何内容,即使文件夹中有一些 html 文件...
    • 突然它开始工作了!!!从昨天开始,我只是 vagrant 重新加载了很多次......并且没有明显的原因它突然开始工作。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2017-06-12
    • 2017-10-08
    • 2015-07-05
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 2020-05-20
    相关资源
    最近更新 更多