Vagrantを試してみようと思っていくつかの記事を見たけど、
汎用としてはいまいちわかりづらかったので自分用にメモ。
※Windowx7/64bit環境
とりあえずインストールする。
Vagrant
Vitrualbox
公開されているboxから欲しいものをさがす。
青字リンク部分の[boxname]でvagrantから指定する。
割と使いそうなBox
CentOS centos/7
Ubuntu ubuntu/trusty64
作業ディレクトリで、コマンドプロンプトから。
vagrant box add [boxname]
vagrant init [boxname]
vagrant up
デフォルトのネットワーク設定だけなので、WebなりにつかうPort Forwardは設定すること。
Vagrantfileに追記。
config.vm.network "forwarded_port", guest: 80, host: 8080
ホストの8080がゲストの80へ転送されます。
設定変更後はVMを再起動すること。
vagrant halt
vagrant up
起動Log
D:\VagVM\lamp1>vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
box: URL: https://atlas.hashicorp.com/laravel/homestead
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.
1) virtualbox
2) vmware_desktop
Enter your choice: 1
==> box: Adding box 'laravel/homestead' (v0.2.6) for provider: virtualbox
box: Downloading: https://atlas.hashicorp.com/laravel/boxes/homestead/versio
ns/0.2.6/providers/virtualbox.box
box: Progress: 100% (Rate: 1353k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'laravel/homestead' (v0.2.6) for 'virtualbox'!
D:\VagVM\lamp1>vagrant init laravel/homestead
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
D:\VagVM\lamp1>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: lamp1_default_1430707456633_49658
==> 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:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if its present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => D:/VagVM/lamp1
D:\VagVM\lamp1>