5

I'd like to set umask to 002 for the php-fpm process. I'm reading here and here that on Ubuntu/Debian it is supposed to be done by modifying the init script.

I'm having doubts however that this is the proper way. Just thinking about the case php5-fpm gets updated and an update modifies the init script.

I also read here that for CentOS/Redhat you can set it via /etc/sysconfig/.

So my question is whether there is a proper way on Debian/Ubuntu to set the umask without modifying the init script? In case there is not, is it OK to modify the init script directly?

Attila Fulop
  • 193
  • 1
  • 10

3 Answers3

2

I know this is old, but for anyone else who comes along modifying www.conf and adding env[UMASK] = 0002 solved the problem. Note the three 000 before the 2, no two as in the respondent's answer above.

MikeD
  • 21
  • 2
  • Also, don't forget to remove or chown any files that were created under the old username. I had a cache directory that needed to be removed before the new settings could take affect. – MikeD Jan 05 '18 at 02:47
  • What is the difference between 002 and 0002? According to this https://stackoverflow.com/a/13269502/1016746 there is none. – Attila Fulop Jan 05 '18 at 07:36
1

You can always change Umask for whole Systemd service by adding config file /etc/systemd/system/my-service-name-whatever.d/umask.conf with content like:

[Service]
UMask=0002
Martin
  • 111
  • 1
1

Corresponding to the debian maintainer you can use the /etc/apache2/envvars for apache, so maybe there is a corresponding file for phpfpm? Also systemd has a umask setting in unit files, however I don't think it is honored if the service does not have a native systemd unit file.

Sophie
  • 117
  • 4
  • Thanks for your response. I think what you're writing is correct and partially applies to php-fpm as well. Having a similar approach you can set envvars in `/etc/php5/fpm/pool.d/www.conf` by adding lines like `env[TMP] = /tmp`. But the apache *envvars* file it's more like a script, and the php-fpm pool config is really just a config file. I also tried adding `env[UMASK] = 002`, obviously without any effect :) – Attila Fulop May 27 '15 at 15:23