「.NET 開発基盤部会 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
目次 †
概要 †
Linuxを触りたかったので、SHIRASAGIハンズオンの開発環境準備をしてみた。
開発環境の準備 †
以下を参考にして、開発環境を準備する。
- SHIRASAGIハンズオンの開発環境は、Vagrant + VirtualBox?で準備する。
インストール †
64ビット Windows †
私はWin 10 proを用意しました。
VirtualBox?をインストール †
- VirtualBox?
Oracle社のホストOS型の仮想マシン。
- 注意
- Hyper-V とは同居できない。
- default VM folder を日本語を含まないディレクトリにする。
参考: incompatible character encodings: CP850 and Windows-1252
Vagrantをインストール †
※ SHIRASAGI開発環境として、動作確認のとれた vagrant バージョンをインストールする。
- Rubyで実装されていて、Windows、Mac OS X、Linuxで動作する。
- VirtualBox?をはじめとする仮想マシンやChefやSalt、Puppet
といった構成管理ソフトウェアのラッパーとみなすこともできる。
- Vagrantを用いると、構成情報を記述した設定ファイルを元に、
仮想マシンの構築から設定までを自動的に行うことができる。
Tera Termをインストール †
Tera Term などの SSH クライアントが必要。
- Tera Term
- SSH・telnet・シリアルの各通信プロトコルに対応したリモートログオンクライアント
- Microsoft Windowsで使用できる。
開発環境の構築 †
Vagrantによる環境設定
Vagrantfileというファイルを作成 †
Vagrantfile は Ruby の簡単な変数代入で書かれている。
公式にも「Rubyの知識は必要ない」と書いてある。
- 内容
Vagrant.configure(2) do |config|
config.vm.box = "ss-vagrant-v1.6.0-rc"
config.vm.box_url = "https://github.com/shirasagi/ss-vagrant/releases/download/v1.6.0-rc/ss-vagrant-virtualbox-x86_64.box"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "private_network", ip: "192.168.33.11"
config.vm.network "private_network", ip: "192.168.33.12"
config.vm.provider :virtualbox do |vb|
# see: http://blog.shibayu36.org/entry/2013/08/12/090545
# IPv6 と DNS でのネットワーク遅延対策で追記
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
end
end
Vagrantを使用し開発環境を起動 †
- 以下のような表示がされるので、暫く待つ。
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ss-vagrant-v1.6.0-rc' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'ss-vagrant-v1.6.0-rc' (v0) for provider: virtualbox
default: Downloading: https://github.com/shirasagi/ss-vagrant/releases/download/v1.6.0-rc/ss-vagrant-virtualbox-x86_64.box
default: Progress: nn% (Rate: nnnnk/s, Estimated time remaining: n:nn:nn)
- default: SSH auth method: private key から先に進まない。
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
- 問題を分析するために、GUIモードを有効にする(以下をVagrantfileに追加)
vb.gui = true
- 以下のコマンドを再実行する。
>vagrant up
- 以下、試行錯誤
- VirtualBox?のコンソールを開いたら、設定に問題がある旨が表示されていたので修正。
[ディスプレイ] ---> [リモートディスプレイ] ---> [サーバーを有効化]のチェックをオフ
- 仮想ウィンドウに「This kernel requires an x86-64 CPU, but only detected an i686 CPU.」が表示される。
開発環境への接続 †
仮想ウィンドウで接続 †
GUIモードが有効な場合、仮想ウィンドウを使用できる。
Tera Termで接続 †
以下からTera Termで接続する。
共通 †
- ホストOSからブラウザで "http://localhost:3000/" にアクセスすると、SHIRASAGIのCMSサイトにアクセスできる。
これは、ポートフォワーディングでホスト:3000からゲスト:3000(Web Server)に接続しているため。
Windows の共有フォルダにマウント †
Windows 版 Vagrant Box の共有ファイルは非常に遅く、
Windows の共有フォルダを使った方が、 早くて快適なので、
必要に応じてWindows の共有フォルダにマウントする。
CIFSをインストール †
- 以下を実行してroot権限を要求しパスワードを再入力。
Windowsの共有フォルダを作成 †
- Windows 側で開発ディレクトリを www という名前で作成・共有
- Microsoftアカウントでないローカルアカウントを作成して、
共有フォルダとNTFSの両方にアクセス許可を与えておく。
共有フォルダをマウント †
ちなみに、10.0.2.2は、VirtualBox?のゲストOSからホストOSにアクセスするIP。
マウントの確認 †
以下コマンドで、マウントできたかどうかを確認できる。
動作確認 †
以下のサイトに接続可能かどうか確認する。
自治体サンプルサイト †
http://localhost:3000/
企業サンプルサイト †
http://192.168.33.10:3000/
子育て支援サンプルサイト †
http://192.168.33.11:3000/
オープンデータサンプルサイト †
http://192.168.33.12:3000/
LPサンプルサイト †
http://192.168.33.13:3000/
グループウェア †
http://localhost:3000/.g1
管理画面 †
http://localhost:3000/.mypage
参考 †
VirtualBox? †
Vagrant †
Tera Term †
default: SSH auth method: private key †
から先に進まない。ググると色々出てくるが、
平たく言って、諸事情によりOSが起動していないケースが多い。
シラサギハンズオン in 広島 †
懇親会 候補 †
で、実際は、
でやった。