LoginSignup
1
1

More than 5 years have passed since last update.

VafrantBox

Posted at

boxファイルの追加

Vagrant ではあらかじめOSがインストールされたboxファイルを使用して仮想マシンを作成します。
以下からOSを選んでダウンロード、登録します。
今回は Ubuntu13.04 を使います。

1
// boxの登録。結構時間かかります。
2
$ vagrant box add ubuntu13.04 http://goo.gl/ceHWg
これで ubuntu13.04 という名前の box が作られました。

1
// 追加されているか確認
2
$ vagrant box list
3
ubuntu13.04 (virtualbox)
Vagrant の初期化

1
$ mkdir ubuntu13vm
2
$ cd ubuntu13vm
3
$ vagrant init ubuntu13.04
vagrant initを実行するとカレントディレクトリに Vagrantfile が作成されていると思います。
こちらが Vagrant の設定ファイルになります。
Chefなどのプロビジョニングの設定や同期フォルダの設定、ネットワークの設定が出来ます。

Vagrantfileのネットワークの設定を少しいじってみましょう。

1

config.vm.network "private_network", ip: "192.168.33.10"

2

3
config.vm.network "private_network", ip: "192.168.33.10"
これで起動したときの仮想マシンのIPが192.168.33.10になります。
WEBサーバなどを立ち上げた時に上記のIPでアクセスできます。

Vagrant の起動

さて起動してみましょう。初回のみ時間がかかります。

1
$ vagrant up
立ち上がったら起動した仮想マシンに入ってみましょう。

1
$ vagrant ssh
2
Welcome to Ubuntu 13.04 (GNU/Linux 3.8.0-19-generic x86_64)
3

4
* Documentation: https://help.ubuntu.com/
5
Your Ubuntu release is not supported anymore.
6
For upgrade information, please visit:
7

8
http://www.ubuntu.com/releaseendoflife
9

10
New release '13.10' available.
11
Run 'do-release-upgrade' to upgrade to it.
12

13
Last login: Wed Jun 12 06:36:33 2013 from 10.0.2.2
14
vagrant@raring64-vanilla:~$
入れました。
vagrantというユーザーでログインしています。

抜けたいときはexitで抜けましょう。

ためしに仮想マシンにApacheをいれてブラウザで表示してみましょう。

1
// Apacheのインストール
2
vagrant@raring64-vanilla:~$ sudo aptitude -y install apache2
インストールできたら先ほど設定したIPアドレスにブラウザでアクセスしていみましょう。

ブラウザ

無事アクセスできました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1