I’m developing a php application and I would like to mount /var/www to /www.
I have ran chown -hR www-data:www-data /var/www
.
What I want to achieve is to be able to create new files and directories with www-data as the owner and www-data as the group using my local account without issues.
So I have decided to mount /var/www to /www using sudo mount --bind /var/www /www
so that all local accounts can modify it also files and directories will be created as www-data:www-data
but i can’t get it to work.
2
Answers
I was able to resolve the issue by taking these steps.
sudo apt install bindfs
sudo usermod -a -G www-data "$LOGNAME"
/var/www/shared/user /home/user/Projects/www-data fuse.bindfs create-for-user=www-data,create-for-group=www-data,mirror=@www-data 0 0
Files created under /home/user/Projects/www-data looks like they are owned by user but are created as
www-data:www-data
Output from
ls -l /home/user/Projects/www-data
:Output from
ls -l /var/www/shared/user
:I think what you’re looking for here is the
setfacl
command, which sets the default permissions for a specified directory. After you mount the directory, try the following:If you want to change the existing permissions as well, add the
-R
flag: