Vagrant Laravel Homestead - 运行 vagrant up 时出错

3

我已经按照https://laravel.com/docs/5.0/homestead上的教程操作,但在运行“vagrant up”步骤时,出现以下错误消息(如下所示)。有什么想法吗?正在运行最新版本的Oracle VirtualBox和最新版本的Vagrant。谢谢

--

C:\Users\Anders\Vagrant\Homestead>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead-7
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 (guest) => 8000 (host) (adapter 1)
    default: 443 (guest) => 44300 (host) (adapter 1)
    default: 3306 (guest) => 33060 (host) (adapter 1)
    default: 5432 (guest) => 54320 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
GuestAdditions versions on your host (5.0.16) and guest (5.0.12) do not match.
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
linux-headers-3.19.0-25-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the
 box /tmp/VBoxGuestAdditions.iso
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting rea
d-only
Installing Virtualbox Guest Additions 5.0.16 - guest version is 5.0.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.16 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.12 of VirtualBox Guest Additions...
Stopping VirtualBox Additions ...fail!
(Cannot unload module vboxguest)
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Stopping VirtualBox Guest Addition service  ...done.
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used

Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 5.0.16. Some
 functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Anders/Vagrant/Homestead
    default: /home/vagrant/Code => C:/Users/Anders/Code
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3`,
actimeo=1 home_vagrant_Code /home/vagrant/Code
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,actimeo=1 home_vagran
t_Code /home/vagrant/Code

The error output from the last command was:

unknown mount option `actimeo=1'
valid options:
  rw         mount read write (default)
  ro         mount read only
  uid       =<arg> default file owner user id
  gid       =<arg> default file owner group id
  ttl       =<arg> time to live for dentry
  iocharset =<arg> i/o charset (default utf8)
  convertcp =<arg> convert share name from given charset to utf8
  dmode     =<arg> mode of all directories
  fmode     =<arg> mode of all regular files
  umask     =<arg> umask of directories and regular files
  dmask     =<arg> umask of directories
  fmask     =<arg> umask of regular files

C:\Users\Anders\Vagrant\Homestead>

--

--

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

--

YAML文件:

--

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/Vagrant/Homestead/homestead.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code
      to: /home/vagrant/Code
      type: "nfs"

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public
      hhvm: true

databases:
    - homestead

你的 Homestead.yaml 文件包含 '制表符' 而不是空格。 - Can Celik
谢谢 - 似乎修复了一些问题。现在我又遇到了另一个错误。 - AHL
3个回答

6

你遇到的问题与Homestead已经在Github上有记录。提供了一个解决方法,如下所示:

解决方案:在Homestead.yaml文件夹中删除type:“nfs”。

http://docs.vagrantup.com/v2/synced-folders/nfs.html

“Windows用户:NFS文件夹不适用于Windows主机。Vagrant将忽略你在Windows上请求同步的NFS文件夹。”


原始回答(在编辑之前的问题)

现在问题似乎与您的ssh密钥有关,或者缺乏它。

No such file or directory @ rb_sysopen - C:/Users/Anders/.ssh/id_rsa (Errno::ENOENT)

在您提供的指南中,标题为“设置SSH密钥”的章节(您提供的链接)提供了以下说明来帮助您生成SSH密钥(仅限Windows部分):

设置SSH密钥

[...]

在Windows上,您可以安装 Git 并使用包含在Git中的 Git Bash shell 来执行上述命令。或者,您也可以使用 PuTTYPuTTYgen

创建SSH密钥后,请在您的Homestead.yaml文件的authorize属性中指定密钥的路径。

如果您不太熟悉命令行操作,建议使用PuTTYgen方法。

1
谢谢Brian Morton -> 我通过GitShell在Windows上发出了命令并解决了问题。上面编辑了新的问题。 - AHL
@AHL,您能否澄清一下您目前的问题是什么?由于所有的编辑,原始问题现在变得相当混乱! - Brian Brownton
@AHL,我已经更新了答案以反映您问题的更新。 - Brian Brownton
谢谢Brian - 这就是问题所在。另外一个问题:我应该把我的代码放在哪里,以便我可以在http://192.168.10.10:8000/访问它?我把文件放在C:\Users\Anders\Vagrant\Homestead\Code下,但是当我尝试在主机中的浏览器中访问http://192.168.10.10:8000/时,出现了“无法连接”的错误。 - AHL
@AHL,你可能需要开一个单独的问题因为那是另一个问题,但作为一个开始,你可以运行sudo netstat -lnutp来查看是否在该列表中出现:8000nginx(它们应该会出现)。如果没有出现,这意味着vagrant box上的Web服务器nginx未运行。 - Brian Brownton
删除类型为“nfs”的设置对我很有帮助。Win 10,Vagrant 1.9.7,laravel 5.4,homestead。 - Yevgeniy Afanasyev

2
如果有其他人通过谷歌搜索到这里,但并没有好好阅读所有的评论(就像我一样),那么请注意:
我遇到了同样的问题,无法使用命令“vagrant up”,并出现以下错误:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o actimeo=1,nolock,uid=1000,gid=1000 var_www_dev.mybox /var/www/dev.mybox

The error output from the command was:

  fmask     =<arg> umask of regular files

正如Lucas在这里提到的那样,Windows用户可以安装vagrant-winnfsd插件,使您可以在Vagrant和Homestead中使用NFS共享文件夹。
所以我通过运行vagrant plugin install vagrant-winnfsd然后再运行vagrant up解决了这个错误。

2
这是一个关于你的Homestead.yaml文件在~/.homestead目录中出现问题。我需要查看文件内容才能更好地帮助你。
当你修复了缩进样式只使用空格字符后,另一个问题出现了,因为你还没有生成一对(公钥和私钥)。要做到这一点:
mkdir -p ~/.ssh && cd ~/.ssh
ssh-keygen -b 2048 -t rsa -C "you@domain.com"
您可以让默认文件名(id_rsa),输入密码并重复相同的密码。

谢谢Lucas -> 我通过Windows上的GitShell发出命令并解决了问题。新问题已在上面编辑。 - AHL
我从未使用过vagrant-login和vagrant-vbguest,也许后者是问题的原因。尝试删除它“vagrant plugin uninstall vagrant-vbguest”,并在您的主机上安装nfs内核服务器“sudo apt-get install nfs-kernel-server”。 - Lucas Silva
我能否在Windows机器上安装nfs-kernel-server?或者这只适用于基于Linux的主机? - AHL
1
在Windows上,您可以安装一个vagrant插件来添加对NFS的支持:vagrant plugin install vagrant-winnfsd。(https://github.com/winnfsd/vagrant-winnfsd) - Lucas Silva

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接