前回、"ubuntu-14.04-amd64-vbox.box" をBoxに追加したので、今回は構成をみていく。
[結果]
OS | Ubuntu 14.04 LTS 64bit |
---|---|
Phusion Passenger | 未インストール |
ruby | 1.9.3 |
Rails | 未インストール |
Apatch | 未インストール |
MySQL | 未インストール |
仮プロジェクト作成
Box名を確認する。
コマンド:vagrant box list
PS C:\Users\hoge> vagrant box list ubuntu-14.04-amd64-vbox (virtualbox, 0) PS C:\Users\hoge>
"ubuntu-14.04-amd64-vbox" というBox名で追加したことが確認できた。
カレントディレクトリをVagrant環境にするために初期化
コマンド: vagrant init [box-name] [box-url]
PS D:\work\hoge> vagrant init ubuntu-14.04-amd64-vbox A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. PS D:\work\hoge>
カレントディレクトリにファイル「Vagrantfile」が生成されていることを確認。
Vagrant環境構築
「Vagrantfile」を開いて"private_network"だけコメント外した。
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.10"
Vagrantfileに応じて、 ゲストマシンを生成/設定する。
コマンド: vagrant up
PS D:\hoge> vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'ubuntu-14.04-amd64-vbox'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: hoge_1409887644320_58307 ==> default: Clearing any previously set forwarded ports... ==> default: Fixed port collision for 22 => 2222. Now on port 2200. ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 => 2200 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2200 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => D:/hoge ==> default: Checking for host entries PS D:\hoge>
Vagrant環境にSSH接続
Windows PowerShellでは接続できないのわかっているが、とりあえず次のコマンドを打つ。
コマンド: vagrant ssh
PS D:\hoge> vagrant ssh `ssh` executable not found in any directories in the %PATH% variable. Is an SSH client installed? Try installing Cygwin, MinGW or Git, all of which contain an SSH client. Or use the PuTTY SSH client with the following authentication information shown below: Host: 127.0.0.1 Port: 2200 Username: vagrant Private key: C:/Users/hoge/.vagrant.d/insecure_private_key PS D:\hoge>
Host: 127.0.0.1
Port: 2200
Username: vagrant
とのこと。デフォのPasswordは"vagrant"なのでこの情報でSSHクライアントを使って接続する。
※Portはデフォ:2222だが、他でvagrant使っているので自動的に他のPort割り当ててくれてる。
自分はPutty、Tera Termといくつか使っているが、最近お気に入りの「RLogin」で接続した。
Box環境の確認
cat /etc/lsb-release
Ubuntu 14.04 LTS
vagrant@ubuntu-14:~$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS" vagrant@ubuntu-14:~$
arch
64bit
vagrant@ubuntu-14:~$ arch x86_64 vagrant@ubuntu-14:~$
ruby -v
ruby 1.9.3
vagrant@ubuntu-14:~$ ruby -v ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux] vagrant@ubuntu-14:~$
rails -v
未インストール
vagrant@ubuntu-14:~$ rails -v The program 'rails' can be found in the following packages: * ruby-railties-3.2 * ruby-railties-4.0 Try: sudo apt-get install vagrant@ubuntu-14:~$
passenger-config --version
未インストール
vagrant@ubuntu-14:~$ passenger-config --version passenger-config: command not found vagrant@ubuntu-14:~$
apache2 -v
未インストール
vagrant@ubuntu-14:~$ apache2 -v The program 'apache2' is currently not installed. You can install it by typing: sudo apt-get install apache2-bin vagrant@ubuntu-14:~$
mysql
未インストール
vagrant@ubuntu-14:~$ mysql The program 'mysql' can be found in the following packages: * mysql-client-core-5.5 * mariadb-client-core-5.5 * mysql-client-core-5.6 * percona-xtradb-cluster-client-5.5 Try: sudo apt-get install vagrant@ubuntu-14:~$
[VagrantによるRails環境 関連記事]