LoginSignup
2
2

More than 5 years have passed since last update.

Vagrantで仮想環境構築する

Posted at

インストール

最初に、仮想環境を動かすためにVirtualBoxを下記URLよりインストールします。
https://www.virtualbox.org/

次にVagrantを下記URLよりインストールします。
https://www.vagrantup.com/

ご自身の環境のものをインストールしてください。

Vagrantがインストールできたかは、
vagrant -v
で確認します。
下記のようにバージョンが表示されれば、インストールは成功です。
Vagrant 1.7.4

仮想環境のテンプレートを取得

次に、仮想環境のテンプレート(box)を取得します。
下記URLの表から使用したい環境を選びます。
http://www.vagrantbox.es/

次のコマンドを実行し、テンプレート(box)を取得します。
vagrant box add test https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
取得したboxは
vagrant box list
で確認することができます。

仮想環境を起動

次に仮想環境を起動させます。
mkdir hoge
cd hoge
vagrant init test
これでhogeディレクトリの中にVagrantfileというものが作成されます。
仮想環境のいろいろな設定が記述されています。

次のコマンドを実行すると、仮想環境が起動します。
vagrant up
VirtualBoxで起動されているか確認しましょう。

次のコマンドで仮想環境に接続することができます。
vagrant ssh

まとめ

VirtualBoxとVagrantをインストールして、簡単なコマンドを実行するだけで仮想環境が作れちゃいます。

2
2
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
2
2