LoginSignup
28
29

More than 5 years have passed since last update.

vagrantとchefとdockerによるRails開発環境構築(centosを導入)

Last updated at Posted at 2014-08-03

vagrantによるcentos立ち上げ

 vagrantで仮想サーバを立ち上げるには、initによる初期化とupによる立ち上げが必要なので、早速行ってみる。

$ vagrant init centos
$ vagrant up

 おっとエラーが発生してしまいました。

An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file 
実行ディレクトリ/centos

 つまり、centosなんてファイルはないぞ!と言ってるんですね。
 vagrantのosを提供しているところを探してみると、いいところ発見!
 http://www.vagrantbox.es/
 ここだと、virtualboxからvmwareやparallelsまで提供しているんですね。
 では、早速利用してみます。
 一覧にあるosから好きな場所のurlをコピーして、vagrant box addで追加すればいいです。
 今回はvirtualboxのcent os6.5を利用してみます。

$ vagrant box add centos https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box

 osを取得してるんで、しばらく時間がかかります。
 追加が終わったら、再度実行。

$ vagrant up

 またしても、エラーがでた。
 次は、なんだろうか。

The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

 つまり、もうvirtualboxが動いているから実行出来ませんといっているのかな?
 状態を確認してみるかな。

$ ps aux | grep vagrant
$ vagrant status

 別に動いていなそう。
 原因不明なので、GUI起動をtrueに変更。
 vagrant initを行ったときに作成されたVagrantfileを編集する。

  ### 変更前
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Don't boot with headless mode
  #   vb.gui = true
  #
  #   # Use VBoxManage to customize the VM. For example to change memory:
  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
  # end

  ### 変更後
  #
  config.vm.provider "virtualbox" do |vb|
    # Don't boot with headless mode
    vb.gui = true
  #
  #   # Use VBoxManage to customize the VM. For example to change memory:
  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
  end

 再度実行してみるとvirtualboxでエラーがでていた。

Kernel driver not installed (rc=-1908)

Make sure the kernel module has been loaded successfully.

 調べてみると、virtualboxの再インストールで解決できるようなので、再インストールを行ってみる。

$ vagrant up

 起動後のdefaultは

user: root
password: vagrant

 vagrantの起動まで終了です。

vagrantにnginxの導入とchef等について

 vagrantとnginxについては別ページに用意しています。

28
29
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
28
29