s

Windows + Vagrant + Ubuntu 14.04

Capistrano とか Fabric とかを気軽に試したくて Vagrant を使ってみることにした。

VirtualBox をインストールする

以下ページから該当ファイルをダウンロードしインストールする。

https://www.virtualbox.org/wiki/Downloads

Vagrant をインストールする

以下ページからダウンロードしインストールする。

https://www.vagrantup.com/

仮想サーバを立ち上げる

box を追加する

Ubuntu 14.04 の box を追加するには以下のようにする

$ vagrant box add ubuntu14.04 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box

参考 http://blog.kondoyoshiyuki.com/2014/06/12/windows7-vagrant-ubuntu14-04/

ディレクトリを作成する

$ mkdir -p ~/Vagrant/sample

設定ファイルのひな形を作成する

$ cd ~/Vagrant/sample
$ vagrant init

このようにするとディレクトリ内に Vagrantfile というファイルが作成されます。

さきほど追加した Ubuntu を利用するように設定ファイルを編集します。

  config.vm.box = "ubuntu14.04"
  config.vm.network "private_network", ip: "192.168.50.12" ←これは断念した

※ホストオンリーネットワークを使おうと思ったら管理者権限が必要で断念した。。

仮想サーバを立ち上げる

# vagrant up

でサーバが起動します。すごく簡単。

仮想サーバにログインする

$ vagrant ssh

このコマンドでログインできました。

Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-55-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Wed Jun 24 03:37:33 UTC 2015

  System load:  0.92              Processes:           79
  Usage of /:   3.3% of 39.34GB   Users logged in:     0
  Memory usage: 29%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


vagrant@vagrant-ubuntu-trusty-64:~$