对ruby语法感兴趣的可以移步这里学习哈!ruby语法文档
对vagrantfile配置参数感兴趣的可以移步这里学习哈!vagrantfile配置参数
我这里使用的virtualbox
作为虚拟机软件,当然你也可以使用Hyper-V
作为虚拟机软件。
hosts =
[
{
:define => 's56.5', :hostname =>'s56.5',
:private_network => '192.168.56.5',
:vb_name => 'ubuntu_192.168.56.5',
:synced_folder =>{
:local => 'E:/code/test/php/vagrant/code5',
:virtual => '/data/www/'
},
:forwarded_port => [
{:guest => 8000, :host => 8000},
{:guest => 8001, :host => 8001},
{:guest => 8444, :host => 8444},
{:guest => 8443, :host => 8443},
{:guest => 8080, :host => 8080,:auto_correct => true},
{:guest => 1337, :host => 1337,:auto_correct => true}
]
},
{
:define => 's56.6', :hostname =>'s56.6',
:private_network => '192.168.56.6',
:vb_name => 'ubuntu_192.168.56.6',
:synced_folder =>{
:local => 'E:/code/test/php/vagrant/code6',
:virtual => '/data/www/'
},
:forwarded_port => [
{:guest => 8000, :host => 8000,:auto_correct => true},
{:guest => 3306, :host => 3306},
{:guest => 8500, :host => 8500},
{:guest => 80, :host => 8999,:auto_correct => true},
]
}
]
Vagrant.configure("2") do |config|
config.vm.box = "traefik_box"
hosts.each do |item|
config.vm.define item[:define] do |host|
host.vm.hostname = item[:hostname]
item[:forwarded_port].each do |port|
if port[:auto_correct]
host.vm.network "forwarded_port", guest: port[:guest], host: port[:host], auto_correct:port[:auto_correct]
else
host.vm.network "forwarded_port", guest: port[:guest], host: port[:host]
end
end
host.vm.network "private_network", ip: item[:private_network]
host.vm.synced_folder item[:synced_folder][:local], item[:synced_folder][:virtual]
host.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.cpus = "1"
vb.name = item[:vb_name]
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
end
end
end
end