如何让多机 Vagrant 文件使用一台虚拟机?
How to get multi-machine Vagrant file to use one 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
感谢您的帮助,
Is there a way to have a multi-machine setup where each config uses the same machine?
不,你不能,1 台配置机器 = 1 台虚拟机,所以当你写的时候
config.vm.define "myoffercode" do |vm1|
vm1.vm.synced_folder "/Users/gregoryschultz/Sites/myoffercode", "/var/www/html"
end
它确实创建了一个由 vagrant 管理的新 VM
I design websites and I would like to my VM to be configured to run as a webserver with an IP address and have each config to load the sync folder and domain name.
解决方案是使用 1 个虚拟机并使用 Virtual hosts
因此在您的 VM 中同步所有项目
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
指向这些网站
有没有一种方法可以让每个配置都使用同一台机器进行多机设置?我设计网站,我希望将我的虚拟机配置为 运行 作为具有 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
感谢您的帮助,
Is there a way to have a multi-machine setup where each config uses the same machine?
不,你不能,1 台配置机器 = 1 台虚拟机,所以当你写的时候
config.vm.define "myoffercode" do |vm1|
vm1.vm.synced_folder "/Users/gregoryschultz/Sites/myoffercode", "/var/www/html"
end
它确实创建了一个由 vagrant 管理的新 VM
I design websites and I would like to my VM to be configured to run as a webserver with an IP address and have each config to load the sync folder and domain name.
解决方案是使用 1 个虚拟机并使用 Virtual hosts
因此在您的 VM 中同步所有项目
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
指向这些网站