Group permissions on web folder

Posted April 1, 2015 6k views
Linux Commands

I think I’m at the forest for the trees and frustrated as hell. Ok so I want to be able to have chown access to my wp-content by www-data AND my login, call it MyLogin. So wordpress can upload and I can use WinSCP to upload via MyLogin.

I have looked over all the docs and added MyLogin to the www-data group but that doesn’t work…what am I missing. Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

ACL (Access Control Lists) would be easiest.

For Ubuntu:

##Install acl:
sudo apt-get install acl -y

Next, we need to set up the mount to handle it. If you’re running Ubuntu >= 14.04, you can ignore this next bit:

Configure fstab

edit /etc/fstab. It will look something like this:

UUID=b96601ba-7d51-4c5f-bfe2-63815708aabd /               ext4    noatime,errors=remount-ro 0       1

After noatime, add “,acl” so it looks like this:

UUID=b96601ba-7d51-4c5f-bfe2-63815708aabd /               ext4    noatime,acl,errors=remount-ro 0       1

Next, run this so the change takes effect:

mount -o remount /

Now, let’s check that it’s working:

mount |grep acl

You should see something like this:

/dev/vda1 on / type ext4 (rw,noatime,acl,errors=remount-ro)

If you don’t, let me know.

Configuring the ACL

Now, on to setting the ACL (changing the path to the path you need, and MyLogin to your actual login):

sudo setfacl -m u:MyLogin:rwx /var/www/

Now, let’s see if that worked:

sudo getfacl /var/www/

If it worked, it will look something like this:

# file: /var/www/
# owner: www-data
# group: www-data

As you can see, you now have full permissions.

Differences for CentOS/Fedora

to install acl, run this:

yum -y install acl

to edit /etc/fstab, the line needed changing will look like this:

LABEL=DOROOT       /               ext4    errors=remount-ro 0       1

Change it to look like this:

LABEL=DOROOT       /               ext4    acl,errors=remount-ro 0       1

All other things will be the same.