Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On my server I have set up several user accounts for different purposes to separate my personal websites from my semi-pro websites.

Some of these websites are Wordpress sites and I'm trying to enable image upload. The files in the home directory are obviously owned by that specific user however, I have added Apache (www-data) to the group of that user so in theory if I give a directory and it's contents chmod -R g+w then that directory should be writable by Apache (and the PHP process), correct?

As you might understand, this is not whats currently happening and I'm not sure how to make this work. What I don't want is to assign all the files to belong to www-data and then add the user to the www-data group. I believe the files should belong to the user first and foremost and www-data has only limited permissions.

What would be the best way to fix and/or troubleshoot this?

Edit:

Thanks for the responses so far, what I'd like to point is that on my development machine (Ubuntu) I have the exact same set up. Eclipse projects are stored in a sub-directory of my home directory and simply by doing a chmod -R g+w on required directories I have the PHP process under Apache write to those directories. I'm not using any ACL's what so ever for this.

However, for some reason on my server this is not working which is a bit puzzling.

Update 2:

What might be a difference between my dev machine and my server is that on my dev machine files are like this:

-rw-r--r-- 1 luke luke 34 2012-11-14 04:30 .some.file

And on my server this looks like:

-rw-r--r-- 1 luke wheel 34 2012-11-14 04:30 .some.file

I guess the group here has an influence.

share|improve this question

3 Answers 3

I prefer to use ACLs for this. For instance:

setfacl -R -m user:www-data:rwx,d:user:www-data:rwx \
         /home/luke/www.luke.com/wp-content/uploads

Gives the www-data user full access to the uploads directory and everything below it.

share|improve this answer

Can www-data execute the parent directory? Try to su - to the www-data user, cd to the dir and touch a file. If you can't cd to the dir, try changing directory in progressively from / . ACLs will also work if your filesystem is mounted with that option.

share|improve this answer
up vote 0 down vote accepted

I hate answering my own questions since it feels like I've wasted everyone's time.

The problem had indeed to do with the fact that my user and group were set to luke wheel. After changing this to luke luke with a chown -R luke:luke uploads and a chmod -R g+w /home/luke/www.luke.com/uploads it all seemed to work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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