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.

Yesterday, I was finally able to get my apache process to write files to a directory by setting the umask to 002 in the /etc/sysconfig/httpd script, but I was wondering if it's possible to set this umask directive at the config layer?

I am seeking to do this for portability reasons, because my vhost configs are version controled and published to remote servers. I'd prefer not being forced to manually configure each server's httpd script (no puppet yet).

Thanks.

-- Edit --

Using Ruby/Capistrano to deploy code and config files

Using PHP mkdir() when creating files uploaded by users.

Rather than set a directory to 777, I am creating a specific 'filer' user / group which will own the directory. Then add the apache user to the group. If I don't set the umask to 002 then I get permission denied errors because apache user != filer user, but apache user is in the filer group.

share|improve this question
    
Are you talking about webdav, svn, or some kind of cgi/webapp (PHP, perl, ruby, etc). What are you using, the answer may be the configuration relatvant to whatever intrpreter you are using. –  Zoredache Jan 27 '12 at 1:44
    
Updated question. –  Mike Purcell Jan 27 '12 at 1:48

1 Answer 1

up vote 1 down vote accepted

Since you are using PHP code you can just use the PHP functions chmod() and umask() depending on the need.

The main Apache umask seem to only be configured the way you already figured out, not anywhere in the configuration itself, so doing it in the application/code is the best way.

share|improve this answer
    
Ya I considered this, but according to PHP, us3.php.net/umask, it's not wise to use umask in multi-threaded environments. If I can't do it at the config layer, I'll just stick with setting at the script layer. –  Mike Purcell Jan 27 '12 at 3:44
    
Ultimately ended up just manually calling chmod programatically. Thanks. –  Mike Purcell Feb 4 '12 at 4:17

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.