Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Allow specific user permission to read/write my folder

I have a folder, /home/oliver, which is the home directory for my user oliver. I am going to set up a file server and would like the apache user to be able to read from this folder.

At the moment the apache user can’t see this folder at all.

What are the commands to do this? I’m new to Linux so I don’t understand the concept of groups etc.

share|improve this question

marked as duplicate by Kyle, Ƭᴇcʜιᴇ007, Nifle, Sathya Dec 7 '12 at 15:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 1 down vote accepted

You have a group oliver which is the current group of your home folder. You need to add apache to this group. Use usermod -a -G oliver apache as root (probably using sudo) to add the apache user to the group oliver. You will need to restart apache (or your machine) to apply the change.

After this you can control the permissions with the group permission. Write access isn't usually given by default to other group members, so you may want to run chmod -R g+w /home/oliver. That adds write permission (+w) for other members of the group (g), recursively (-R). You own the folder, so you do not need sudo for that.

Keep in mind that apache may not run under the username apache. It may be something such as www, www-data, or webuser. Either check top/ps to see what it is running as, or run cat /etc/passwd and see which user looks like apache uses it. More specific instruction would require what distribution you are running and what version.

share|improve this answer
    
Thanks for explaining how the groups work. Is it safe to assume that we can give apache rights to everything owned by the oliver group, as I only want the home directory? –  Oliver Joseph Ash Oct 21 '12 at 16:30
    
Well, in general the only things owned by the oliver group are in your home directory, since that's where 'your' things are. Of course, you could make a folder owned by apache and add yourself to its group so you can edit. –  ssmy Oct 21 '12 at 18:06

If you have ACL's enabled, then a quick way would be to set an ACL for Apache, as in:

setfacl -m u:apache:r /home/oliver

For additional details man setfacl and man getfacl.

share|improve this answer
1  
I don’t have ACL enabled and I’m not sure how to enable it (running Centos 5.8). –  Oliver Joseph Ash Oct 21 '12 at 16:09

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