3

我正在尝试在 Windows 8.1 x64 上设置 Laravel 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: casensitive_default_1420409560257_10693
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    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: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...

Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

这是 Homestead 的一个非常流行的错误,我在 stackoverflow 上发现了几个类似的帖子,例如:onetwo。但是在我的 Vagrantfile 中设置 boot_mode 并不能解决问题。

Vagrant.configure("1") do |config|
  config.vm.boot_mode = :gui
end

为了确保我有 VT-x,我下载了 intels 工具,我这样做了:i7 core;我检查了 BIOS 中是否启用了虚拟化。

在我使用默认值的 Vagrantfile 中(其中大部分似乎已被注释掉)并且我已将 config.vm.box 设置为:

"laravel/homestead"

我的 Homestead.yaml 设置为(并且已经有 id_ras.pub 和 id_rsa):

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

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/d/projects
      to: /home/vagrant/projects

sites:
    - map: roopla.app
      to: /home/vagrant/projects/test_app/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

这与我正常的 Composer、PHP、GruntJS、BowerJS、AngularJS 日相差甚远,而且我不确定我真正在做什么,最初我只是在学习 Laravel 4/5,然后我侧身跳了起来,因为 Homestead 看起来很有用和kewl,所以我只是盲目地遵循指示,所以任何可以传授的知识片段都将不胜感激。

4

1 回答 1

0

首先,确保您没有打开Hyper-V.

其次,您的 ssh 密钥可能有问题。最简单的解决方案是更改您的 vagrant 文件,不使用 SSH 密钥,而是使用登录名和密码。

看看我的流浪文件:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"

homesteadYamlPath = File.expand_path("Homestead.yaml")
afterScriptPath = File.expand_path("after.sh")
aliasesPath = File.expand_path("aliases")

require_relative '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

    config.ssh.username = "vagrant"
    config.ssh.password = "vagrant"   

    Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))    

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

    config.vm.network "forwarded_port", guest: 11300, host: 11301
end

我在这里添加了 2 行:

    config.ssh.username = "vagrant"
    config.ssh.password = "vagrant"  

因为我和你有同样的问题,现在 Homestead 为我工作,没有任何问题。

于 2015-01-11T14:58:59.503 回答