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

I am having a go at setting up my own Apache and can't seem to get my head around the permissions.

Lets say I grab a file from somewhere off the web and it has permission of 600.

I then upload this file via ftp to a user directory, which is also an apache virtual site, and so this file retains this permission of 600. This means that the user can read this file, but Apache can't: it will be forbidden.

What is the most simple solution so that apache can read + write whatever files end up in the users directory? Can apache be granted some sort of root power over files in a directory?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

You can use ACL to give apache the permissions to the whole subtree or use ACL for everything (ftp users and apache) :). I would use ACL for everything as I think it is easier and better to keep everything working in the same direction.

ACL guide on CentOS

share|improve this answer

You could consider mod_userdir.

If you have a directory inside the user home directory called 'public_html'

chgrp apache /home/username/public_html
chmod 750 /home/username/public_html
chmod g+s /home/username/public_html

then this will mean new files created in that directory will be automatically readable by the apache group.

share|improve this answer

Short answer: chmod to 660 will allow the Group apache and the mentioned user is in to write to the files - you might have to add the ftp user to the apache Group.

Long recommeneded answer: http://www.csgnetwork.com/csgchmodcalc.html - if your ftpd supports it, you can set chmod permissions via ftp.

share|improve this answer
    
Wouldn't that mean I'd need to chmod every time I upload the files? I know how I can manually chmod the files to change their permissions, but I'm looking for a way that means apache will be considered to have the same permission as the user. –  willdanceforfun Nov 7 '12 at 12:36
    
of course you can change the ftpds umask or upload username - or apaches. –  mojo Nov 7 '12 at 12:38

you could take a look at using "inotifywait". This lets you watch for changes in a directory and files. this website http://hardc0l2e.wordpress.com/2012/03/13/folder-monitoring-script-using-inotifywait/ contains a script that simply outputs the files changed. You could update it to do whatever you want, for example to chmod the files to your wishes!

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.