Whenever apache (apache2) creates a file or directory it automatically sets the permissions to 777. I want it's directories to be 775 and files 664. How can I fix this?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Check /etc/bashrc. It should already (at least on a CentOS machine) have the following stanzas:
# /etc/bashrc # System wide functions and aliases # Environment stuff goes in /etc/profile # By default, we want this to get set. # Even for non-interactive, non-login shells. if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi
This should already be getting you the behavior you want, unless you installed a custom apache, and created the apache user yourself. Even then, it shouldn't be getting 000 as the umask unless that's already explicitly set up somewhere. I mention this only because your system is exhibiting signs of a non-standard config, and because of that, it's possible that other users (system or otherwise) are also getting this far too broad file creation mask.