Setting the umask of the Apache user

Viewed 88647

I am setting up a LAMP server and would like to set Apache's umask setting to 002 so that all Apache-created files have the group write permission bit set (so members of the same group can overwrite the files).

Does anyone know how to do this? I know that on Ubuntu, you can use the /etc/apache2/envvars file to configure the umask, but the server is running CentOS.

Update This question is related to another I asked a while ago (Linux users and groups for a LAMP server). If prefered, please update this other question with what the best set-up is to use for having a developer user on a server that can edit files created by the apache user.

11 Answers

Apache inherits its umask from its parent process (i.e. the process starting Apache); this should typically be the /etc/init.d/ script. So put a umask command in that script.

Luoti's answer work for me on CentOS7.

System boot or reboot is not required.

You may get this warning when you restart the service using command systemctl restart httpd

`Warning: httpd.service changed on disk. Run 'systemctl daemon-reload' to reload units`.

So first run systemctl daemon-reload command then systemctl restart httpd

Drifting away from the "tried and true Apache way" is usually not recommended. Lots of time and hard won experience has gone into the selection of such things.

Related