Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission not maintained for newly created files while using vagrant

I'm using vagrant with precise64 box & a Laravel 4 project. I've set Storage folder to be writable (777 only works for me) and every time a new file created, session for example, I need to manually set yet again the new file to be writable.

Is there any option to set newly created files to be writable in order to prevent this kind of issue in the future?

edit: Here is an example of ll -la output on the session folder containing new session (done from the vagrant box), maybe it'll help.

vagrant@precise64:/myfinalproject$ ll -la ./app/storage/sessions/
total 16
drwxrwxrwx 1 vagrant vagrant 4096 Jul  9 04:29 ./
drwxrwxrwx 1 vagrant vagrant 4096 Jun 10 12:57 ../
-rwxrwxrwx 1 vagrant vagrant   13 Jun 10 12:57 .gitignore*
-rw------- 1 vagrant vagrant  229 Jul  9 04:29 sess_u8ov414cgie6v3afmkgn3net33
like image 932
Shahar Galukman Avatar asked Jul 08 '13 19:07

Shahar Galukman


People also ask

Which command should I use for changing a file permission?

The chmod command enables you to change the permissions on a file. You must be superuser or the owner of a file or directory to change its permissions.

What is permission value for a file read only for the group owner?

755 - owner can read/write/execute, group/others can read/execute. 644 - owner can read/write, group/others can read only. Some directory permission examples: 777 - all can read/write/search.


1 Answers

I was having a very similar, possibly the same, permissions issue. I could view the site once and then all requests after would result in a permission error.

Try adding the following code to your VagrantFile:

# Set the ownership of the app/storage directory
config.vm.synced_folder "app/storage", "/vagrant/app/storage", :owner => 'www-data', :group => 'www-data'

Hopefully that helps you. The following source provided me with the solution: https://github.com/experience/vagrant-laravel-application/blob/master/Vagrantfile

like image 144
dbrown428 Avatar answered Oct 01 '22 18:10

dbrown428