oikynブログ

エンジニアの技術ブログ。主にWEB、iOS、サービス、ツールなどなど。

Vagrant + Windows7

Windowsで開発するのに、xamppとかwampとかありますが、 最近主流なのが、

Vagrant

ですね

もちろんmacでも使えます。

VirtualBox

ダウンロード&インスト

https://www.virtualbox.org/wiki/Downloads

4.3系はネットワーク周りに不具合あるらしく、

4.2系がいいらしい。(現状)

https://www.virtualbox.org/wiki/Download_Old_Builds

Vagrant

ダウンロード&インスト

http://downloads.vagrantup.com/

OSイメージ

http://www.vagrantbox.es/

セットアップ

$ vagrant box add {title} {url}
$ vagrant init {title}
$ vagrant up

ちなみに、私がインストしたものは

http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box

設定ファイル(Vagrantfile)

vagrantを起動する前に、とりあえずこれだけ設定すればOKかな。

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "CentOS_64" #ボックス名
    config.vm.network :forwarded_port, guest: 80, host: 80 #フォワードポート
    config.vm.synced_folder "./data", "/var/vagrant_data" #共有フォルダ
end

SSH

Winからは、puttyPoderosaからsshできます。

Host: 127.0.0.1
Port: 2222
Username: vagrant

Private key: ***/.vagrant.d/insecure_private_key
or
Password:vagrant

基本コマンド

# 開始
vagrant up

# 終了
vagrant halt

# 破壊
vagrant destroy

# ステータス
vagrant status

  

sshで入って、ApacheMySQLPHPなど基本を入れて、

http://localhost

と入れて確認できます。