I have a virtual web server running linux and on that I have a user called "user". this is also the user, that i use when i mount the webserver's directory with sshfs. sadly this user cannot write any files for the website i am working on, only the user www-data is allowed to do that. if i use: chown -R user:user ./
to change the owner, i am allowed to change the data as "user", but now the website cannot be opened in the webbrowser anymore. so i have to change the owner of the files back, after i am done editing the files which is extremely tedious.
I have added the user "user" to the www-data group, but this is not changing anything.
How can I set everything up in a way, that the user "user" can edit the files as well as www-data?
CodePudding user response:
You need to change the permissions for your files so members of the same group are allowed to write. You can do this with the chmod g w -R ./
command, this works for existing files.
However, you will notice that newly created files will be created with the owner set to user:user
, which would still deny access to www-data
. You can change this behavior by setting the default ACL like so: setfacl -R -d -m g:www-data:rw ./
The setfacl options mean:
-R
Recursive-d
Action applies to default ACL-m
Modify the ACLg:www-data:rw
Set group by default towww-data
and group permission to read and write.