Published on

Vagrant のインストールメモ


インストール前に古い Vagrant がインストール済みだったのでアンインストール

$ sudo rm -rf /Applications/Vagrant
$ sudo rm -rf /usr/bin/vagrant
$ sudo pkgutil --forget com.vagrant.vagrant


$ vagrant --version
Vagrant 1.7.2 でcentos6.5を取得
$ vagrant box add centos65

box add時にエラー発生
Vagrant failed to initialize at a very early stage:
The home directory you specified is not accessible. The home
directory that Vagrant uses must be both readable and writable.
You specified: $HOME/.vagrant.d


$ rm -rf ~/.vagrant.d/
$ vagrant box add centos65
==> box: Adding box 'centos65' (v0) for provider:
box: Downloading:
==> box: Successfully added box 'centos65' (v0) for 'virtualbox'!
$ vagrant box list
centos65 (virtualbox, 0)
$ mkdir -p ~/work/vagrant/sample
$ cd ~/work/vagrant/sample
$ vagrant init centos65
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
`` for more information on using Vagrant.

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos65'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: sample_default_1434785939617_19449
==> 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:
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
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 => ~/work/vagrant/sample

nginx をインストールする

$ vi
echo "Nginx install..."
sudo rpm -ivh
sudo yum -y install nginx
sudo service nginx start
sudo chkconfig nginx on

$ vi Vagrantfile
config.vm.provision "shell", path: ""

$ vi Vagrantfile
# Create a private network, which allows host-only access to the machine
# using a specific IP. "private_network", ip: ""

# 無事アクセス成功
$ vagrant ssh
$ curl -v

# 仮想マシンを削除しておく
$ vagrant halt
$ vagrant destroy