I have user1 which is member of group www-data.

$ groups user1
> user1 : user1 www-data

I am unable to add/delete something under /var/www/test

The /var/www/test is owned by www-data

$ ls -l /var/www/test
> drwxr-sr-x 2 www-data www-data 4096 aug 11 12:02 subtest

How to allow user1 to manage files and directories created by www-data ?

I already tried to

  • Change the primary group of user1 to www-data
  • Logout / login

Try Below:

sudo chgrp -R www-data /var/www/test
sudo chmod -R g+w /var/www/test


sudo find /var/www/test -type d -exec chmod 2775 {} \; 

sudo find /var/www/test -type f -exec chmod ug+rw {} \;

I hope you understand significance of above command as they are pretty clear.

Do not forget to Logout/Login.


I finally found something cleaner

Adding the web directory in the personnal directory of the user

mkdir -p /home/user1/websites/appOfUser1
chown -Rf user1:user1/home/devone/websites
chmod -Rf 770 /home/user1/websites

Then adding this line is /etc/fstab (install bindfs before)

bindfs#/var/www/application1 /home/user1/websites/appOfUser1 fuse force-user=user1,force-group=user1,create-for-user=www-data,create-for-group=www-data,create-with-perms=0770,chgrp-ignore,chown-ignore,chmod-ignore 0 0  

And finally mount it!

mount /home/user1/websites/appOfUser1
  • it solves the concurrency problem, as every user in the equation (every developers and the web server) sees the permissions that he requires to operate properly and safely;

  • it solves the impermeability problem, as if you need one developer to access a particular application, you have to add a mountpoint in its home directory, but on the contrary, if the you need one developer to not access a particular application, you just have to not add such a mountpoint in it's home directory.

  • it solves the stability problem, as developers will never be able to change the file permissions set on the application files, as required by the web server to operate properly and safely.

  • best of all, it's simple to understand and to setup !


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.