有没有办法让多机器设置每个配置使用同一台机器?我设计网站,我希望我的VM配置为作为具有IP地址的网络服务器运行,并让每个配置加载同步文件夹和域名。
这是我到目前为止所做的:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, host: 8080, guest: 80
config.vm.network "private_network", ip: "172.28.128.3"
config.vm.define "myoffercode" do |vm1|
vm1.vm.synced_folder "/Users/gregoryschultz/Sites/myoffercode", "/var/www/html"
end
config.vm.define "dailybayou" do |vm2|
vm2.vm.synced_folder "/Users/gregoryschultz/Sites/dailybayou", "/var/www/html"
end
end
感谢您的帮助,
答案 0 :(得分:2)
有没有办法让多机器设置每个配置使用同一台机器?
不,你不能,1配置机器= 1 VM所以当你写
config.vm.define "myoffercode" do |vm1|
vm1.vm.synced_folder "/Users/gregoryschultz/Sites/myoffercode", "/var/www/html"
end
它确实创建了一个由vagrant管理的新VM
我设计网站,我希望将我的VM配置为作为具有IP地址的网络服务器运行,并让每个配置加载同步文件夹和域名。
解决方案是使用1个VM并使用Virtual hosts
所以在您的虚拟机中同步所有项目
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, host: 8080, guest: 80
config.vm.network "private_network", ip: "172.28.128.3"
config.vm.synced_folder "/Users/gregoryschultz/Sites/myoffercode", "/var/www/html/myoffercode"
config.vm.synced_folder "/Users/gregoryschultz/Sites/dailybayou", "/var/www/html/dailybayou"
end
以及Apache的配置
# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
DocumentRoot "/var/www/html/dailybayou"
ServerName dailybayou.localdev
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/myoffercode"
ServerName myoffercode.localdev
# Other directives here
</VirtualHost>
确保将本地主机文件更新为指向这些网站的172.28.128.3