Apache 2.4 with PHP-FPM, set Umask

I thought I’d share my happiness with this one. I had a DEVIL of a time setting the umask that I needed for some Web applications (I need 0002 so that several users can edit certain files created by Apache). Google’s highly redoubtable AI suggested that I use “systemctl edit [service name],” starting with httpd, and add “[Service]\nUMask=0002.” Reloaded the systemctl daemon, restarted httpd, ran a little PHP test program that created a file … no good. Permissions were still set to user write only.

More searching suggested editing the php-fpm.service. I did so, added the same lines. Still no good. I entered what had to be the World’s Longest Google Query, stating everything I’d tried; Google suggested that I grep the proc directory for the umask. It reported “UMask=0002.” Restarted systemctl daemon, restarted httpd, entered “[Service]/UMask=0002” in php.ini, php-fpm.ini and anywhere I thought it might work. Each time, I restart the daemon, restarted httpd, wiped hands on pants … no dice.

Finally – even though the Web server was active and I really didn’t want to do this during the day – I entered “shutdown -r now” to force a reboot and closed my eyes. Once the Web server came back up, HAH! The umask was set correctly. My test file ls’d to “rw rw r”, which is what I wanted.

I have no idea which “UMask=0002” line in which file did the actual magic. But the reboot seemed to do the trick. NONE of the search results ever required that. Ergo, I post here in case someone else is having problems setting the umask for files created by a Web page.

Sometimes a good, sold reboot is the answer. This was apparently one of those times.

1 Like