Best strategy for permissions - webserser user and logged in developer
nightowl77 opened this issue · comments
Hi Guys
Does anyone have a specific stategy for permissions on Linux? My main user (the one I log in with) is different from my webserver. This causes problems when I do a basset:build from the commandline, and there is usually some clash with collections.json under app/storage/meta.
The "linux way" of fixing this is of course to add my login user to the webserver's group. This however does not always work because directories are created on the fly as 0755 (ie, only the user that created it, in this case the web server user, has read, write and execute permissions)
I was wondering if anyone else came up with a nice elegant solution on how to deal with the problem. One idea that might work is to enable the password for the webserver user and then to "su" into that account when I run artisan.
Any ideas/feedback welcome.
You can make the folders/files owned by the webserver group, usually www-data for apache. Then you want to set the s bit of the permissions on the directories where the webserver needs write access, chmod 2775 will give write permissions to group and make sure files and folders created inside this folder are owned by the same group that owns the parent folder. You need 755 on regular directories, 775 on those where apache needs to write. And make sure all of the directories where the application creates files have their group permission bit set to 's'.
Aaah, thank you. That will work perfectly and hopefully a few other developers will find this answer when battling with the same problem.