Group permissions on web folder

April 1, 2015 1.3k 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!

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.

Have another answer? Share your knowledge.