概要
仮想環境(VirtualBox)上に仮想マシンを立ち上げる
環境
ホストマシン
Mac OSX
VirtualBox
vagrant
ゲストマシン
CentOS7.0
コマンド#
以下、Terminalでの手順となる.
VagrantでCentOSを立ち上げる##
まず、ホームディレクトリに移動し、vagrant用のディレクトリを作成
コマンド
$ cd
$ mkdir myVagrant
myVagrantに移動し、CentOS用ディレクトリを作成
コマンド
$ cd myVagrant
$ mkdir myCentos
myCentosに移動し、vagrantの初期化
コマンド
$ cd myCentos
$ vagrant init bento/centos-7.1
Vagrantfileが作成されるので、エディタで編集
コマンド
$ emacs Vagrantfile
29行目に
Vagrantfile
\# config.vm.network "private_network, ip:192.168.33.10"
と書かれた行があるので、コメントを外す.
これでvagrantの初期化が完了したので、
コマンド
$ vagrant up
と入力し、CentOSを起動する。
ここで、下記のエラーが出る場合は、
・VitualBoxが入っていない。
・VitualBoxとvagrantのバージョンが古い
ことが考えられるので、バージョンを確認すると解決できると思います。
error
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
vagrant upが成功すると、CentOSのダウンロード・起動が行われ。
ローカル開発環境の構築が成功する。