从 vagrant box 从浏览器访问文件

Accessing a file from the browser from a vagrant box

我是 Vagrant 的新手/每天都使用 vm boxes,似乎无法弄清楚如何通过浏览器访问我从本地计算机共享到 vm 的文件。我有一个共享文件夹到根 home/vagrant,这是我使用 vagrant ssh 登录时导航到的目录。然后打开浏览器并输入 localhost:8000/index.html 我收到 404 not found.

我知道我做错了一些事情,可能错误地使用了 Vagrant,但同时我觉得我没有将我的共享文件夹指向正确的位置。

-- 编辑--

到目前为止我的 vagrantfile 配置看起来像

Vagrant.configure("2") do |config|
    config.vm.box = "scotch/box"
    config.vm.network "forwarded_port", guest: 80, host: 9001
    config.vm.provision :shell, path: "bootstrap.sh"
    config.vm.synced_folder ".", "/var/www"
end
apt-get update
apt-get install -y apache2
if ! [ -L /var/www ]; then
  ln -fs /vagrant /var/www
fi

我明白了,这是使用

将我的共享文件夹指向虚拟机中正确位置的组合

config.vm.synced_folder "./dist/src", "/var/www"

cding 到那个目录然后使用

php -S <-IP->:8000