I had a problem with a website I was developing in Vagrant where the site neeeded to write out to the /vagrant directory (well actually a symlink that pointed there).
Apache doesn’t have permission to write there by default, but the following change to my Vagrantfile sorted it out.
config.vm.share_folder("v-root", "/vagrant", ".", :owner => "www-data", :group => "www-data")
This makes sure that the /vagrant directory is owned by a user that apache has permission to read and write with.
I hope this helps out others who have had the same problem.
Vagrant Update – October 2013
Newer versions of Vagrant have renamed v-root to vagrant-root, so the line for the VagrantFile is now
config.vm.share_folder("vagrant-root", "/vagrant", ".", :owner => "www-data", :group => "www-data")
Thanks Robert!
This really helped me out.
This is exactly what is needed! Works fine. Newer vagrant versions throw a warning for ‘v-root’ though, but that’s nothing serious!
Thanks. It worked for me.