
我開始從 wamp 遷移到 laravel homestead vagrant box,但在啟動這個盒子時我被難住了。我已經下載並配置了所有資產並運行 vagrant up 來啟動盒子,但是,這是 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 stop 的結果:
$ 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
.
如果它是一次性虛擬機,您可以隨時重複destroy
使用up
。也可以考慮升級 Vagrant 和 Virtualbox。