The format for shared folders changes across different versions of Vagrant. See Fabio's answer https://serverfault.com/questions/398414/vagrant-set-default-share-permissions
config.vm.share_folder "v-data", "/export", "/export",
:owner => 'vagrant',
:group => 'httpd',
:extra => 'dmode=775,fmode=775'
In Vagrant 1.3.1 and later, the extra
option has been replaced with mount_options
that expects an array.
config.vm.share_folder "v-data", "/export", "/export",
:owner => 'vagrant',
:group => 'httpd',
:mount_options => ['dmode=775', 'fmode=775']
In vagrant 1.3.3 it appears config.vm.share_folder
has been replaced with config.vm.synced_folder
.
config.vm.synced_folder "v-data", "/export", "/export",
:owner => 'vagrant',
:group => 'httpd',
:mount_options => ['dmode=775', 'fmode=775']
My issue might be related to yours.
I have a centos vm in vagrant as the guest and win7 as the host.
I can't actually change the permissions in the VM of any folders that are shared with the Host.
will report back if I discover anything useful. Discuss on google group here:
https://groups.google.com/forum/?fromgroups=#!topic/vagrant-up/2JvcoZTuWRI
UPDATE 1: I have also read that you can't create symlinks in shared folders.
UPDATE 2: It seems that I can't change the permissions in the virtual box after it's been created. However in the VagrantFile you can set the permissions on the shared folders to something that suites: I.E.
config.vm.share_folder "v-data", "/export", "/export", :owner=> 'vagrant', :group=>'httpd', :extra => 'dmode=775,fmode=775'
here I have set the owner, group and the permissions that work for us.
I hope this helps.
In Vagrant 1.2.7, version 2 Vagrantfiles are used, so the syntax is slightly different than in previous answers. Underneath is what does the trick for me with CentOS 6.2. I find that using a relative path as the source works best in my situation. It points to the shared folder.
config.vm.synced_folder "./", "/vagrant", owner: 'vagrant', group: 'apache', extra: 'dmode=775,fmode=775'
As stated by Jamie, it still is necessary that you configure it before creation, so use a vagrant reload
after you've edited your overriding Vagrantfile.
VirtualBox doesn't allow changing the owner/permissions for synced folders.
You can change it in the Vagrant file (as answered by others).
Consider changing the owner instead of the group.
Consider also that - if done so that your server can write to files - your server is likely called www-data instead of httpd. Use ps aux | grep nginx
[or apache / lighthttpd] to check.
There are some other options:
config.vm.synced_folder "/var/www/", type: "rsync"
config.vm.synced_folder "/var/www/", mount_options: ["dmode=777", "fmode=666"]
These answers are better described by Ryan Sechreset and Jeremy Kendall.
Change the permissions form the host not the guest. VirtualBox disallows changing permissions on shared files form a guest os.
TLDR; The issue is not that the users on your guest don't have permissions to access your host files. The issue is the executing user of the virtaul box process on your host does not have permissions to write the files in the host. There are two sets of permissions. The guest permissions have to be set just like any other os. You also have to make sure that the virtual box process your guest os is running in has permissions to that folder. If that process only has read access the most any guest user will be able to do is read.
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