我目前正在关注Semmy Purewal的书“学习Web应用程序开发”。在本书的当前部分,我正在学习如何使用VirtualBox和vagrant在我自己的计算机上托管服务器,然后进入它。根据该书,主机的vagrant目录中的任何文件也应该在home / vagrant目录中的客户机上进行镜像,反之亦然。直到最近,情况确实如此,一切正常。
但是,现在当我尝试在我的主机上的文本编辑器中编辑文件并保存它们时,这些更改在我进入我的客户机时没有反映出来。即使重新连接,重新启动流浪汉,甚至重新启动计算机,情况也是如此。
有谁知道为什么会这样?对不起,这是一个新手问题,但正如你从我正在阅读的书中所知,我是所有这些东西的新手。任何帮助是极大的赞赏。
提前致谢,
保
编辑:这是我运行vagrant up
时的输出:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 3000 => 3000 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version o
f
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you
see
default: shared folder errors, please make sure the guest additions within t
he
default: virtual machine match the version of VirtualBox you have installed
on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
default: /vagrant => C:/Users/paul/Projects/Chapter6
default: /home/vagrant/app => C:/Users/paul/Projects/Chapter6/app
default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => C:/Users/paul/Projects
/Chapter6/cookbooks
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: to force provisioning. Provisioners marked to run always will still
run.
这正是我想要的结果:文件夹Chapter6在主机和guest上挂载并共享。唯一的问题是它实际上没有同步...例如,/ Chapter6中有一个名为“server.js”的文件,我最近更新了,如果我在主机上显示cat
它新版本,而来宾计算机上的cat
显示旧版本。有什么帮助吗?
答案 0 :(得分:0)
标准设置是使用Virtualbox的共享文件夹。默认情况下,它安装在guest虚拟机上的/ vagrant(假设它是* nix来宾)。
如果没有装载/流浪汉文件夹,您应该在通过vagrant up
启动虚拟机时注意输出。它将在挂载共享文件夹时输出日志消息。