1. 添加box
vagrant box add --name centos6.8/cms boxname.box
2.初始化admin环境
vagrant init centos6.8/cms admin
3.启动环境
vagrant up
vagrantfile配置文件设置
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| #BOX名称 config.vm.box = "centos6.8/cms" #端口转发 config.vm.network "forwarded_port", guest: 80, host: 80 config.vm.network "forwarded_port", guest: 22, host: 2222 config.vm.network "forwarded_port", guest: 3306, host: 3306 config.vm.network "forwarded_port", guest: 6790, host: 6790 config.vm.network "forwarded_port", guest: 6454, host: 6454 #vagrant中虚拟环境名称 config.vm.box_url = "admin" #vagrant中指定虚拟环境配置 config.vm.define :admin do |ad| #目录共享 主机目录,虚拟机目录 # ad.vm.synced_folder "www", "/data/www" #禁用vagrant的默认共享目录 ad.vm.synced_folder ".", "/vagrant", disabled:false #虚拟机配置 ad.vm.provider "virtualbox" do |vb| #指定vm-name,也就是virtualbox管理控制台中的虚机名称 vb.name = "cms_all_centos6.8" # vagrant up启动时,是否自动打开virtual box的窗口,缺省为false vb.gui = false #指定vm内存,单位为MB vb.memory = "1024" #设置CPU个数 vb.cpus = 2 end end #SSH验证 config.ssh.username = "vagrant" config.ssh.private_key_path = "./id_rsa" end