首页 文章

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

提问于
浏览
5

我试图在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,在guest虚拟机上安装了Apache .

来自this answer,我试过:

客人

  • curl 'http://localhost:80' 返回带有文件列表的html

  • 在主机上, curl -v 'http://localhost:8080' 返回同一页面 .

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

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

1 回答

  • 4

    那个设定:

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

    将使用主机 "." 目录(共享目录)中的任何内容覆盖任何's in the server' s /var/www/html 目录 .

    /var/www/html/index.html 处有's no longer Apache'的默认 index.html 文件,因为您已在Vagrant synced_folder设置中的该位置安装了共享目录 .

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

相关问题