无法使用Vagrant和Ubuntu连接到localhost:8080

Fra*_*ain 5 apache ubuntu vagrant

我尝试在mac os 10.9.4上安装Vagrant和Ubuntu来制作一个本地开发服务器,遵循@fideloper:Vagrant和Apache的强大指示.

Vagrantfile包含:

config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder ".", "/var/www/html"
Run Code Online (Sandbox Code Playgroud)

evreything在此过程中运行良好:安装了Vagrant和virtualbox,在guest虚拟机上安装了Apache.

这个答案,我试过:

  • 在guest上,curl 'http://localhost:80'返回带有文件列表的html
  • 在主机上,curl -v 'http://localhost:8080'返回相同的页面.

但浏览器this webpage is not available在localhost:8080 说.

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

fid*_*per 5

那个设定:

config.vm.synced_folder ".", "/var/www/html"
Run Code Online (Sandbox Code Playgroud)

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

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

根据您的说法,它工作完全正常,您只需开始将自己的 .html 文件添加到共享文件夹中即可!您只是在共享目录中没有 .html 文件可供服务,因此 Apache 会回退到显示那里的文件的索引。