Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing permissions on /vagrant

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
like image 495
SuperJesus Avatar asked Oct 01 '22 00:10

SuperJesus


2 Answers

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.

like image 141
Rixhers Ajazi Avatar answered Oct 05 '22 12:10

Rixhers Ajazi


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"]
like image 34
nomen Avatar answered Oct 05 '22 10:10

nomen