LoginSignup
33
32

More than 5 years have passed since last update.

Windows7にVagrantをインストール

Last updated at Posted at 2014-06-27

その1 / その2 / その3

自分用の備忘録。
http://www1205uf.sakura.ne.jp/wp/world/?p=398
http://d.hatena.ne.jp/naoya/20130205/1360062070
このあたりを真似ただけです。

Rubyをインストール

http://rubyinstaller.org/
DownloadからRuby1.9とDEVELOPMENT KITをダウンロード。
『Ruby 1.9.3-p545』『DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe』だった。
2.0でもいいかもしれませんがRubyはよくわからんので前述のサイトに従った。

Rubyをインストール。
「rubyのパスを通す」にチェックを入れた。

DevKit-tdm-32-4.5.2-20111229-1559-sfx.exeを適当な場所に解凍。
コマンドプロンプトから

> cd 解凍したディレクトリ
> ruby dk.rb init
> ruby dk.rb install

なお、なにをしたかの意味はわかっていない。

VirtualBoxをインストール

https://www.virtualbox.org/
DownloadからVirtualBoxをダウンロード。
『VirtualBox 4.3.12 for Windows hosts x86/amd64』だった。
インストール時に、インストールしたディレクトリを記録しておく。

ユーザー環境変数PathにさきほどのVirtualBoxのパスを追加。
変更していない場合『C:\Program Files\Oracle\VirtualBox』だった。

Vagrantをインストール

http://www.vagrantup.com/
DOWNLOADからWindows版のLatestをダウンロード。
『vagrant_1.6.3.msi』だった。
そのままインストール。
ここでWindowsの再起動があった。

VirtualBoxのvmをインストール

VirtualBoxはただの空HDDなので、中にOSを入れないと動かない。
http://www.vagrantbox.es/
から好きなOSを選択。
今回はCentOSの最新版、『CentOS 6.5 x86_64 (x86_64-20140116.box)』を選択。
種類がありすぎて何が何だかわからぬ。

コマンドプロンプトから
```

cd C:\path\to\vagranfiledir\centos65
vagrant box add centos_65 https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box
vagrant init centos_65
```

vagrant box addで対象のvmをダウンロードしてくる。
ユーザディレクトリ配下の.vagrant.d\boxes以下に保存されるようだ。
vagrant initで設定ファイルVagrantfileが作成されるのだが、何故かカレントディレクトリにできる。
複数の環境で設定を分けたい場合など、Vagrantfileをディレクトリ別に分けとないといけないらしい。
もしかしたら違う設定とかあるかもしれないが、よくわからない上にこれで動いたのでよしとする。

Vagrantfileを編集

    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.network "forwarded_port", guest: 5901, host: 15901
    config.vm.provider "virtualbox" do |vb|
      vb.gui = true
      vb.customize ["modifyvm", :id, "--memory", "1024"]
    end

のコメントを外す。
forwarded_portは値も変更する。
値に何らかの意図があるのかは不明。たぶん適当。
http://qiita.com/snaka/items/4fc6f83022e01daea58a
192.168.33.10はデフォルトのまま。どうしてこのアドレスかは不明。

なお

    config.vm.network "public_network"

を有効にすると外部から見える状態になるので注意。

Vagrantを起動

> vagrant up

This kernel requires an x86-64 CPU, but only detected an i686 CPU.
Unable to boot - please use a kernel appropriate for your CPU.

あふん。
32ビットCPUなので、x86-64のOSは動かねーよという。

VirtualBoxのvmを再度インストール

『CentOS 6.5 i386 Minimal (VirtualBox Guest Additions 4.2.16, Chef 11.6.0, Puppet 3.2.3)』を選択。

> cd C:\path\to\vagranfiledir\centos65
> vagrant box add centos_65 https://dl.dropbox.com/s/3fgr7lbvcpn51py/centos_6-5_i386.box
> vagrant init centos_65
> * Vagrantfile編集
> vagrant up

This kernel requires an x86-64 CPU, but only detected an i686 CPU.
Unable to boot - please use a kernel appropriate for your CPU.

あれー???
どうもcentos_65というvmがvagrant box addでは上書きされず、古いのが起動したっぽい。
仕方ないので名前を変える。

> vagrant destroy
> cd C:\programfiles\vagranfiledir\centos65_32
> vagrant box add centos_65_32 https://dl.dropbox.com/s/3fgr7lbvcpn51py/centos_6-5_i386.box
> vagrant init centos_65_32
> * Vagrantfile編集
> vagrant up

何度もダウンロードしてて無駄っぽいが、対処方法わからず。

Vagrantを起動

> CentOS release 6.5 (Final)
> Kernel 2.6.32-431.11.2.e16.i686 on an i686
> localhost login:

ついにVirtualBoxが起動した。
やれやれ。
で、このID/パスワードは何だ?

http://weblabo.oscasierra.net/windows-vagrant-1/
ID/パスワード共にvagrantで入れた。

Vagrantにログイン

> vagrant ssh

`ssh` executable not found in any directories in the %PATH% variable.

SSHなんてねえよ、Cygwinか何かSSH使えるものを入れろ、って言われた。
さすがにcmdでは駄目だったか。

33
32
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
33
32