在我的 Macbook 上,我使用的是 VirtualBox+Vagrant。对于 Vagrant,我下载了 VagrantPress(来自 vagrantpress.org),这是一个带有 Wordpress 和一些 Puppet 脚本的 Vagrantfile。它看起来像这样:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "base"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.manifest_file = "init.pp"
puppet.options="--verbose --debug"
end
end
起初,它按预期运行(查看 localhost 上的 Wordpress 安装),但我将它安装在 Dropbox 子目录中,并且在尝试让它在另一台运行 Ubuntu 的计算机上工作时,我可能已经改变了一些东西打破了整个设置。
现在,在我的 macbook 上运行“Vagrant up”时(以前运行良好),我看到了:
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8080 (adapter 1)
[default] Booting VM...
GuestAdditions versions on your host (4.2.18) and guest (4.1.12) do not match.
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
dkms set to manually installed.
linux-headers-3.2.0-54-generic is already the newest version.
linux-headers-3.2.0-54-generic set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: warning: /mnt seems to be mounted read-only.
Installing Virtualbox Guest Additions 4.2.18 - guest version is 4.1.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.2.18 Guest Additions for Linux............
VirtualBox Guest Additions installer
You appear to have a version of the VBoxGuestAdditions software
on your system which was installed from a different source or using a
different type of installer. If you installed it from a package from your
Linux distribution or if it is a default part of the system then we strongly
recommend that you cancel this installation and remove it properly before
installing this version. If this is simply an older or a damaged
installation you may safely proceed.
Do you wish to continue anyway? [yes or no]
Cancelling installation.
An error occurred during installation of VirtualBox Guest Additions 4.2.18. Some functionality may not work as intended.
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
cause things such as shared folders to not work properly. If you see
shared folder errors, please update the guest additions within the
virtual machine and reload your VM.
Guest Additions Version: 4.1.12
VirtualBox Version: 4.2
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-puppet/manifests
[default] -- /tmp/vagrant-puppet/modules-0
Chrome 上的 localhost 显示“未收到数据”。之后,我“Vagrant ssh”并运行:
curl 'http://localhost/'
并得到:
cURL Error (7): couldn't connect to host ...
这几天我一直在尝试解决这个问题。我什至尝试重新安装 Vagrant 和 VirtualBox,但没有成功。此外,我尝试手动更新 Guest Additions(尽管之前没有必要),并且在“GuestAdditions 4.2.18 running --- OK”之后。启动虚拟机后,本地主机仍然出现相同的错误。我究竟做错了什么?