I'm unable to access my Apache server within vagrant due to the file permissions and ownership of the /vagrant directory. How can I change the default owner and file permissions for /vagrant ?
The default permissions are as follows drwx------ 1 vagrant vagrant 4096 Apr 18 19:53 vagrant
What changes in the Vagrantfile can I make to override my default permissions?
Vagrant version 1.5.3
My Vagrantfile
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb|
#...
end
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"]
end
In Vagrant API version 2 you can share folders like so:
config.vm.synced_folder "/Direct/Path/To/Your/Folder", "/Direct/Path/To/The/Vagrant/Folder", :owner => "www-data", :group => "www-data"
config.vm.synced_folder "/Direct/Path/To/Another/Folder", "/Direct/Path/To/The/Other/Vagrant/Folder", :owner => "www-data", :group => "www-data"
You would place this information in the blocks after the following text:
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
I had the same problem you are describing, and I fixed it via this method. Hope this helps. Any more information regarding this problem I highly recommend RT(F)M.
Here is one option I looked at when I tried to figure out how to do something similar:
config.vm.synced_folder "./sites", "/var/sites/", id: "vagrant-root",
owner: "vagrant",
group: "www-data",
mount_options: ["dmode=775,fmode=664"]
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