Laravel Vagrant Up SSH问题

5
我正在尝试使用Homestead Vagrant创建一个Laravel应用程序。我使用的是Windows 7开发环境,并采用Per Project Installation。根据Laravel文档,我可以在vagrant up my project时运行vagrant up。但是,在我的项目中运行vagrant up时,会卡在SSH认证方法:password处,并出现以下消息:
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.

我正在使用 Laravel 5.3 和 Vagrant 1.9.0。之前我使用的是 Vagrant 1.8.4,但一旦出现问题,我就安装了 Vagrant 1.9.0,但出现了完全相同的错误。我尝试了这里提供的解决方法,在vb.gui中我看到了启动服务器时出现的以下错误:

[   0.100000] Failed to access perfctr msr (MSR c0010007 is 0)
  lvmetad is not active yet, using direct activation during sysinit
  lvmetad is not active yet, using direct activation during sysinit
Scanning for Btrfs filesystems
/dev/mapper/vagrant--vg-root:clean, 127066/2559088 files, 1241443/10228736 blocks
[  10.420196] piix4_smbus 0000:00:07.0: SMBus base address uninitialized - updrade BIOS or use force_addr=0xadr
[    ] A start jon is running for Raise network interfaces (4 min 44s / 5min 5 s)

然后服务器启动了,我可以登录,但是我的文件夹和Homestead.yaml文件中的IP地址没有设置到服务器上。

这是我的Homestead.yaml文件:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: mysite
name: mysite
provider: virtualbox

authorize: C:/Users/xxx/.ssh/id_rsa.pub

keys:
    - C:/Users/xxx/.ssh/id_rsa

folders:
    - map: "C:/Users/xxx/www/mysite"
      to: "/home/vagrant/mysite"

sites:
    - map: homestead.app
      to: "/home/vagrant/mysite/public"

databases:
    - homestead

当实例正在运行并且我运行:

vagrant ssh-config

我理解了

Host mysite
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes

当我运行时:
vagrant global-status

I get:

id       name   provider   state   directory
-----------------------------------------------------------------------
66eb5bf  mysite virtualbox running C:/Users/xxx/www/mysite

当我尝试使用以下命令从Vagrant获取调试信息时:

vagrant up --debug > vdebug.txt

在命令提示符中生成了很多消息,但只有在vdebug.txt文件中出现了这个:

Bringing machine 'mysite' up with 'virtualbox' provider...
==> mysite: Importing base box 'laravel/homestead'...

[KProgress: 20%
[KProgress: 30%
[KProgress: 60%
[KProgress: 70%
[KProgress: 90%
[K==> mysite: Matching MAC address for NAT networking...
==> mysite: Checking if box 'laravel/homestead' is up to date...
==> mysite: Setting the name of the VM: mysite
==> mysite: Clearing any previously set network interfaces...
==> mysite: Preparing network interfaces based on configuration...
    mysite: Adapter 1: nat
    mysite: Adapter 2: hostonly
==> mysite: Forwarding ports...
    mysite: 80 (guest) => 8000 (host) (adapter 1)
    mysite: 443 (guest) => 44300 (host) (adapter 1)
    mysite: 3306 (guest) => 33060 (host) (adapter 1)
    mysite: 5432 (guest) => 54320 (host) (adapter 1)
    mysite: 22 (guest) => 2222 (host) (adapter 1)
==> mysite: Running 'pre-boot' VM customizations...
==> mysite: Booting VM...
==> mysite: Waiting for machine to boot. This may take a few minutes...
    mysite: SSH address: 127.0.0.1:2222
    mysite: SSH username: vagrant
    mysite: SSH auth method: password

如果您阅读完了这篇文章,谢谢您!我的问题是如何从Homestead.yaml文件中获取我的IP和文件夹并将它们传输到服务器。任何帮助都将不胜感激。如果需要,让我知道我是否可以添加更多信息。我会随时更新我的状态。
编辑1:
我忘记添加我已经启用虚拟化。
编辑2:
我已经将项目文件夹中的Homestead.yaml文件更改为将IP设置为192.168.10.20而不是192.168.10.10,但仍然没有变化。我会继续更新直到找到答案。
编辑3:
尝试更改位于我的项目文件夹中的Vagrantfile以在Vagrant.configure函数中添加以下内容:
config.vm.network "public_network", ip: "192.168.10.20", :bridge => "en1: Realtek PCIe GBE Family Controller #2"

我收到了相同的错误,但我也收到了这个:

Specific bridge 'en1: Realtek PCIe GBE Family Controller #2' not found. You may be asked to specify
which network to bridge to.
3个回答

6
这个错误是因为Ubuntu尝试启动所有网络接口,但您的电缆未连接,然后等待超时。
似乎在导出虚拟机时会出现此问题,更多信息请参见 https://www.virtualbox.org/ticket/15705 您可以编辑Vagrantfile,在Vagrant.configure循环的末尾添加以下行:
 config.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
    end

基本上在最后一个 "end" 之前添加这个。

1
我过去也遇到了同样的错误,那是因为我的计算机虚拟化未启用。
尝试在您的计算机上启用它。要这样做,您需要进入BIOS。 Vagrant stuck connection timeout retrying 上也有有用的信息。

1
谢谢,我忘记在我的问题中添加了这个,但还是投了一票! - user908759

0
[    ] A start jon is running for Raise network interfaces (4 min 44s / 5min 5 s)

https://askubuntu.com/a/841432

该链接展示了如何将DHCP客户端的超时时间从5分钟减少到15秒。我通过VirtualBox登录进行了操作。这对我起作用。

1
欢迎来到[so]。请阅读[answer]。鼓励提供外部资源的链接,但请添加一些上下文说明以便其他用户了解该链接的内容和目的。在引用重要链接时,请引用最相关的部分,以防目标站点无法访问或永久离线。 - pfx

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