Skip to content

在Windows 7上使用 VirtualBox + Vagrant

Published: at 00:00
相关地址
https://www.virtualbox.org/
http://www.vagrantup.com/
http://www.vagrantbox.es/
下载Box
https://github.com/2creatives/vagrant-centos/releases/download/v6.4.2/centos64-x86_64-20140116.box
配置环境变量
设置PATH, PATH=%PATH%;C:\HashiCorp\Vagrant\embedded\mingw\bin
创建
创建一保存映象的目录,例如 d:\vbox, 把 centos64-x86_64-20140116.box 复制到 d:\box, 然后cmd 下 cd d:\box。

增加
vagrant box add base d:\vbox\centos64-x86_64-20140116.box
配置
初始化生成Vagrantfile
vagrant init

Vagrantfile内容

指定box名称
config.vm.box = "base"

端口映射
config.vm.network "forwarded_port", guest: 80, host: 8080

指定内网IP
config.vm.network "private_network", ip: "192.168.33.10"

映射目录
config.vm.synced_folder "../data", "/vagrant_data"

配置virtualbox,显示GUI窗口

config.vm.provider "virtualbox" do |vb|
  vb.gui = true
  vb.customize ["modifyvm", :id, "--memory", "1024"]

end

启动
vagrant up
停止
vagrant halt