我开始从 wamp 迁移到 laravel homestead vagrant box,但是在启动 box 时我遇到了麻烦。我已经下载并配置了所有资产,并运行 vagrant up 来启动 box,但是,这是 vagrant up 的结果:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> 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 => 8000 (adapter 1)
default: 3306 => 33060 (adapter 1)
default: 5432 => 54320 (adapter 1)
default: 22 => 2200 (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:2200
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...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
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.
以下是 vagrant halt 的结果:
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
default: Guest communication could not be established! This is usually because
default: SSH is not running, the authentication information was changed,
default: or some other networking issue. Vagrant will force halt, if
default: capable.
==> default: Forcing shutdown of VM...
问题似乎出在打开 SSH 上。答案在这里https://stackoverflow.com/questions/22575261/vagrant-stuck-connection-timeout-retrying尽管看起来是类似的问题,但没有帮助。
我正在运行 Windows 8.1。
答案1
启动阶段的 SSH 连接超时可能由多种原因造成,例如:
- 系统等待用户交互(例如共享分区尚未准备好),
sshd
配置错误,- 防火墙配置错误(如果不是本地的),
- 你的私钥不匹配,
- 启动过程耗时过长(尝试增加
config.vm.boot_timeout
), - 检查 BIOS 中是否启用了虚拟化(根据评论)。
要调试该问题,请按如下方式运行:
VAGRANT_LOG=debug vagrant up
如果没有明显的异常,请尝试通过vagrant ssh
以下方式从另一个终端连接它:
vagrant ssh-config > vagrant-ssh; ssh -F vagrant-ssh default
如果 SSH 仍然失败,请使用以下命令重新运行图形用户界面(例如config.gui = true
)。
如果不是,请检查正在运行的进程(例如:)vagrant ssh -c 'pstree -a'
或验证您的sshd_config
。
如果它是一次性 VM,您可以随时重复destroy
使用它up
。还请考虑升级您的 Vagrant 和 Virtualbox。