1

I run PHP with FPM on nginx. This is how I set up umask for php.

Occasionally some files written by www-data user have 0644 permissions instead of expected 0664 that I should receive with umask set to 0002. This happens for random files (sometimes for directories too).

Default umask for PHP and FPM combo on Debian is 0022 but my server is set up with 0002. Yet somehow the same line of PHP code sometimes writes 0664 and sometimes 0644 files.

file_put_contents($file, serialize($res));

I even added chmod() line just to make sure but without luck. And it seems random.

file_put_contents($file, serialize($res));
chmod($cacheFile, 0666 & ~umask());

The same thing happens for directories that get 0755 instead of 0775.

How can I prevent that?

Community
  • 1
  • 1
SiliconMind
  • 2,185
  • 4
  • 25
  • 49

0 Answers0