I had some problems with permissions, the programmers of my website wanted me to add the admin user to the apache group and then set some permissions. My knowledge of Linux is quite limited, so I found the following online:

chown -R apache:apache /path/to/webserver/www 
chmod -R g+rw /path/to/webserver/www

This worked perfectly, and all was well for few days (BTW, I used "apache" instead of www-data since I'm on CentOS). Now, they're saying they can't upload files to that folder since it is owned by apache user, while they want it to be owned by apache AND admin user.

How do I add 'admin' to ownership as well in addition to 'apache'?


  • You can't. A file can only have one owner. Also, it's bad security practice to make the entire Document Root be writable by the web-server user (apache). If your web-site needs an upload directory or write access to a text file or sqlite db or whatever make only those specific directories and files writeable by the web-server. Your Doc Root and all its files/dirs should either be owned by the admin user, or owned by some other user but with group admin (or some other group that admin is a member of). – cas Mar 29 '16 at 9:27
  • BTW, don't forget that the Doc Root directory (and all child AND parent dirs) need to be both readable and executable by the web-server user. – cas Mar 29 '16 at 9:31
  • cross posted superuser.com/questions/1058548/… – Anthon Mar 29 '16 at 13:48

Only one user can own a file, in the traditional sense. But on modern unix systems, there's another measure that can be used - access control lists, or ACL:s.

ACL:s are basically additional controls for read, write and execute access in addition to the traditional user/group/other permissions.

To add write permissions to all users in the apache group, regardless of the file permissions, you can set the ACL for the directory to allow writing by all members of the apache group, and make that permission inherited for all files created within the directory.

sudo setfacl -d -m g:apache:rw /path/to/webserver/www

To also make sure the existing files get the same permissions:

sudo setfacl -m g:apache:rw /path/to/webserver/www/*

For more information, see man setfacl and man getfacl.

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