LoginSignup
23
23

More than 5 years have passed since last update.

OSX 10.9 + VirtualBox + Vagrant 環境のセットアップ

Posted at

vagrant のあたりでこけたので備忘録
正しいやり方かはわからない

必要なソフトのダウンロード

VirtualBox

以下からダウンロード
https://www.virtualbox.org/wiki/Downloads

Vagrant

以下からダウンロード
http://downloads.vagrantup.com/

Box

あとで使うので以下から適当なのを選ぶ。(自己責任)
http://www.vagrantbox.es/

これを落とす心構えをした
Debian Wheezy 7.2 amd64 (VirtualBox Guest Additions 4.3.0) (2013/10/19)
https://dl.dropboxusercontent.com/u/197673519/debian-7.2.0.box

Boxの追加

書式はこんな感じ。

$ vagrant box add [つける名前] [boxのURL] 
$ vagrant -v # 存在確認
$ vagrant box add debian_wheezy_64 https://dl.dropboxusercontent.com/u/197673519/debian-7.2.0.box

VMの追加

Vagrant 1.3.5
$ mkdir vm # 適当なワークスペースを作る (任意)
$ cd vm
$ vagrant init debian_wheezy_64 # さっきつけた名前
$ vagrant up
...
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
cause things such as shared folders to not work properly. If you see
shared folder errors, please update the guest additions within the
virtual machine and reload your VM.

Guest Additions Version: 4.1.18
VirtualBox Version: 4.3
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant

こける

boxと手元のvagrantのバージョンにずれがあるのが原因(だと思う)
vagrant-vbguest を使う

$ vagrant halt # いったん落とす
$ vagrant plugin install vagrant-vbguest
$ vagrant up
...
You appear to have a version of the VBoxGuestAdditions software
on your system which was installed from a different source or using a
different type of installer.  If you installed it from a package from your
Linux distribution or if it is a default part of the system then we strongly
recommend that you cancel this installation and remove it properly before
installing this version.  If this is simply an older or a damaged
installation you may safely proceed.

こける

違うやつがあるみたいなことを言っていると思う(英語力)ので、以前のバージョンをいったん消す。

mac$vagrant ssh
vagrant$ dpkg -l | grep virtualbox
なんか出たけどメモってなかった 。
virtualbox guest うんぬん みたいなのがいくつかあったはず
vagrant$ apt-get remove --purge virtualbox-* # いいぐあいに消えるようにする
vagrant$ exit

mac に戻る

$ vagrant up
...
Installing the Window System drivers ...fail!
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.3.2. Some functionality may not work as intended.
stdin: is not a tty
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant

こける

しらん

$ vagrant halt
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
[default] Booting VM...
GuestAdditions 4.3.2 running --- OK.
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant

なんにも変えてないけどリスタートしたら特にエラーなく動いた。
怪しいけど動いたからいったんこれで。

OS10.9とVirtualBoxの相性がとても悪いらしく、OSの再起動ができなくなるとかあるらしいから気をつけよう。
(GUIでVirtualBoxを開かなければとりあえず大丈夫らしい)

おまけ

上記で使ったBoxがフランス語だったのでロケールなど変更

$ sudo dpkg-reconfigure locales
en_US.UTF8
ja_JP.UTF8
を選択
...
les
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = "en_US.UTF-8",
    LC_CTYPE = "UTF-8",
    LANG = "fr_FR.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory

en_US.UTF8とかのインストールは成功してるんだけど、文句を言われる。
ぐぐったら、hostからつなぐときのsshの設定の問題らしい。

$ sudo vi /etc/ssh_config
- SendEnv LANG_LC_*
+ # SendEnv LANG_LC_*

これでいけた。
SendEnvというのは、ローカルの環境変数をssh時に渡すというやつらしい。
誰得すぎる。

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