Ubuntu – chmod u+s in /var/www

12.04Apache2chmodwww

i have a problem at granting the right rights for the right user…

i want to run pootle with apache, so i downloaded pootle. Then i copied it to /var/www, installed it and gave the www-data user rights for the whole folder. As far as good… now i want to copy the translated files from and to the translation-directory (e.g. /var/www/pootle/po/project).
So i created a group (www) added me to the group and executed

sudo chown -R :www /var/www/pootle

ok, so now i have rights to write files into the directory, however, when apache creates a file, its group is www-data…

sudo chmod -R g+s /var/www/pootle

ok, now the group is always "www", as i wanted it to be… now here is the problem:
When i write files to /var/www/pootle they are there, however, with my user as owner, and not, as i awaited, as www-data, although i executed the command:

sudo chmod -R u+s /var/www/pootle

is there a way that i can say that the user who created the file, even if its me, shall be www-data?

thx in advance 🙂

Best Answer

If you run chown without a preceding colon, you will change the owner. (With the preceding colon, you change the group, as you have demonstrated above, and you can also run chown -R new-owner:newgroup.) So if you just run

sudo chown -R www-data /var/www/pootle

you will change the owner to www-data.

"....when apache creates a file, its group is www-data..."

Can you clarify what you mean by this? Apache serves files, it doesn't create them. PHP creates them - but they are created dynamically and served directly to web clients (browsers), they are not created and then saved by Apache.

It seems your problem is with file ownership. If so, a more convenient approach might be to add pootle to the www group - as Apache (generally) needs htm(l) files to be owned by www to read them. Files then created by Pootle will have the same group ID and you won't need to run chown at all - Apache will have read access to Pootle's files. See http://translate.sourceforge.net/wiki/pootle/apache which says:

 You need to extract Pootle in a directory accessible to the apache user.

Make sure Apache has read access to all of Pootle's files and write access to the dbs and po subdirectories.

Hope this helps.

Related Question