Laravel Homestead 无法正常工作,只是不断超时

标签 laravel vagrant virtualbox laravel-5 homestead

我正在尝试在 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 上发现了一些类似的帖子,例如:one ,和two 。但在我的 Vagrantfile 中设置 boot_mode 并没有解决问题。

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

为了确保我有 VT-x I downloaded 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 看起来很有用而且很奇怪,所以我只是盲目地遵循指示,因此任何可以传授的知识片段都将非常感激。

最佳答案

首先,请确保您尚未打开 Hyper-V

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

看看我的 Vagrant 文件:

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

我在这里添加了两行:

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

因为我遇到了和你一样的问题,现在 Homestead 可以为我工作,没有任何问题。

关于Laravel Homestead 无法正常工作,只是不断超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27771240/

相关文章:

laravel - 使用 csrf_token 时出现未知错误。拉维尔

php - 如何在 Laravel 中向数据库中插入多行?

mysql - Laravel wherebetween with orwherebetween

Builder.php 中用于路由的 Laravel 5 ModelNotFoundException

linux - Vagrant 无法在 Windows 7 上使用 VirtualBox Guest Additions 在 Linux guest 中挂载

JBoss HTTP Transport 不是 Vagrant 的端口转发

vagrant - 在哪里可以找到config.vm.boot_timeout?

macos - Vagrant 是否应该对每个命令都要求 sudo?

Laravel Homestead - 页面停止工作 ERR_ADDRESS_UNREACHABLE

vagrant - Vagrant + VirtualBox VM sleep 后中止