Laravel Homesteadのvagrant upでSSHがこける問題の恒久的な解決策
諸事情がありLaravelを触ることになったのだけど、開発環境構築を楽にしてくれる?というHomesteadで見事にずっこけたのでメモ。
環境
- OS : Mac Sierra
- Vagrant : 1.9.6
- VirtualBox : 5.0.16 r105871
- Homestead : 5.4
事象
vagrant up
をすると以下のようにSSHの部分でこける。
vagrant up Bringing machine 'blog' up with 'virtualbox' provider... ==> blog: Importing base box 'laravel/homestead'... ==> blog: Matching MAC address for NAT networking... ==> blog: Checking if box 'laravel/homestead' is up to date... ==> blog: Setting the name of the VM: blog ==> blog: Clearing any previously set network interfaces... ==> blog: Preparing network interfaces based on configuration... blog: Adapter 1: nat blog: Adapter 2: hostonly ==> blog: Forwarding ports... blog: 80 (guest) => 8000 (host) (adapter 1) blog: 443 (guest) => 44300 (host) (adapter 1) blog: 3306 (guest) => 33060 (host) (adapter 1) blog: 5432 (guest) => 54320 (host) (adapter 1) blog: 8025 (guest) => 8025 (host) (adapter 1) blog: 27017 (guest) => 27017 (host) (adapter 1) blog: 22 (guest) => 2222 (host) (adapter 1) ==> blog: Running 'pre-boot' VM customizations... ==> blog: Booting VM... ==> blog: Waiting for machine to boot. This may take a few minutes... blog: SSH address: 127.0.0.1:2222 blog: SSH username: vagrant blog: SSH auth method: private key 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.
こいつは困ったということでググることに。 そしたら以下の記事を見つけた。
Laravel homesteadで最初のVagrant upが止まる - kz-engineer -SCRAP-
で、やると確かに destroyしてup中にケーブル接続にチェックを入れれば
問題なくup出来た。
けど、これ毎回やりたいか?
というので、更にググったら解決策が見つかった。
ssh - Laravel Homestead vagrant up times out - Stack Overflow
解決策
以下を Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
の間に追加する。
config.vm.provider 'virtualbox' do |vb| vb.customize ['modifyvm', :id, '--cableconnected1', 'on'] end
VirtualBox限定なのでproviderを変えたら消さなきゃだけどとりあえずはバージョンアップまでこれで対応すればよいかな。 Homested.yamlの書き方を工夫して掛けるなら誰かその方法を書いてくれるとありがたい。