Vagrant VM with laravel 4 application, mkdir() file permissions denied for new folders and sub directories

StackOverflow https://stackoverflow.com/questions/19538288

Pregunta

I am running a vagrant VM and have a laravel application which uses a folder called assets to create a directory to store sub directories and files. Once a folder has been created the permissions are only set to read only. Even when using the sudo command to change the permissions to the directory, the error persists.

Config for the vagrant file;

Vagrant.configure("2") do |config|
  config.vm.box = "wheezy64"
  config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210.box"

  config.vm.network "private_network", ip: "192.168.36.49"

  config.vm.synced_folder "./", "/var/www", id: "webroot", :group => "www-data", :owner => "vagrant", :nfs => false

  config.vm.usable_port_range = (2200..2250)
  config.vm.provider :virtualbox do |virtualbox|
    virtualbox.customize ["modifyvm", :id, "--name", "premierPortal"]
    virtualbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    virtualbox.customize ["modifyvm", :id, "--memory", "1024"]
    virtualbox.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
  end

  config.vm.provision :shell, :path => "shell/initial-setup.sh"
  config.vm.provision :shell, :path => "shell/update-puppet.sh"
  config.vm.provision :shell, :path => "shell/librarian-puppet-vagrant.sh"
  config.vm.provision :puppet do |puppet|
    puppet.facter = {
      "ssh_username" => "vagrant"
    }

    puppet.manifests_path = "puppet/manifests"
    puppet.options = ["--verbose", "--hiera_config /vagrant/hiera.yaml", "--parser future"]
end

  config.ssh.username = "vagrant"

  config.ssh.shell = "bash -l"

  config.ssh.keep_alive = true
  config.ssh.forward_agent = false
  config.ssh.forward_x11 = false
  config.vagrant.host = :detect
end

I have tried changing the groups and the owners within the vagrant config file and reloading the vm with the new settings but nothing seems to be working. The only thing that works is changing each of the permissions by hand each time a folder is created.

¿Fue útil?

Solución

You want to add "mount_options" to the end of your config.vm.synced_folder like so (mine here for example, you only need the end bit obviously!):

config.vm.synced_folder "deploy", "/var/www", id: "vagrant-root", :mount_options => ["dmode=777","fmode=666"]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top