Laravel 4 Permissions on a Vagrant box with Puppet Laravel 4 Permissions on a Vagrant box with Puppet laravel laravel

Laravel 4 Permissions on a Vagrant box with Puppet


After some discussion on Twitter, figured out the following:

There's a constraint from VirtualBox on vagrant that does not allow you to set permissions for the synced folder from inside the guest OS. See this issue on github.

You can use the following code to set the synced folder permissions from the vagrant file:

config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"]

Or you can change the Apache runtime user to vagrant from the puppet manifest like so:

exec { "change_httpd_user":    command => "sed -i 's/www-data/vagrant/g' /etc/apache2/envvars",    onlyif => "/bin/grep -q 'www-data' '/etc/apache2/envvars'",    notify => Service['apache2'],    require => Package['apache2'],}file { "/var/lock/apache2":    ensure => "directory",    owner => "vagrant",    group => "vagrant",    require => Exec['change_httpd_user'],}

Or any combination of the above


I'm not using pupphet in my setup and I came up with 2 solutions:

(1) In my bootstrap.sh file:

sudo sed -i 's/APACHE_RUN_USER=.*/APACHE_RUN_USER=vagrant/g' /etc/apache2/envvarssudo sed -i 's/APACHE_RUN_GROUP=.*/APACHE_RUN_GROUP=www-data/g' /etc/apache2/envvars

(2) Im my VagrantFile:

config.vm.synced_folder "./", "/vagrant", id: "vagrant-root" , :owner => "vagrant", :group => "www-data"config.vm.synced_folder "./app/storage", "/vagrant/app/storage", id: "vagrant-storage",    :owner => "vagrant",    :group => "www-data",    :mount_options => ["dmode=775","fmode=664"]config.vm.synced_folder "./public", "/vagrant/public", id: "vagrant-public",    :owner => "vagrant",    :group => "www-data",    :mount_options => ["dmode=775","fmode=664"]