I am attempting to get to grips with vagrant and chef. If I download the opscode cookbook apache2 from git, checkout latest tag and do the following in my Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.forward_port 80, 8080
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "chef/cookbooks"
chef.add_recipe("apt")
chef.add_recipe("apache2")
chef.add_recipe("apache2::mod_rewrite")
end
end
...I end up with a VM with apache installed and working but (after some digging I found that) /var/www is not the documentroot it is infact /etc/apache2/htdocs
Do I need to add a line to my Vagrantfile to configure the document root?
Any help would be appreciated!
Guest Ubuntu 12.04
This solution fits in the Vagrantfile :
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, host: 8080, guest: 80
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "apt"
chef.add_recipe "apache2"
chef.json = {
"apache" => {
"default_site_enabled" => true,
"docroot_dir" => "/vagrant"
}
}
end
end
Doing this way you don't need to launch a site by SSH each time you "Vagrant up".
No. In Vagrantfile you configure your virtual machine (such as memory, hostname, ports) and recipes that should be run (in provision part). But changing apache document root requires changing the apache recipe. Check out the attributes/default.rb and change the required path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With