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?


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.

  • 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 5 '18 at 2:47
  • What is the difference between 002 and 0002? According to this stackoverflow.com/a/13269502/1016746 there is none. – Attila Fulop Jan 5 '18 at 7:36

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.

  • 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

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:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.