Modifying default umask for PHP-FPM

2,108 views
Skip to first unread message

ominds

unread,
Dec 24, 2011, 12:06:21 PM12/24/11
to highload-php-en
I want files written by PHP-FPM to have umask 0002 without having to
modify each PHP application and call the umask() PHP function. Is
there a way I can do that?

I have way too many scripts, many of which are ready PHP apps (e.g.
wordpress, Drupal) that I prefer not modifying individually. PHP-FPM
is called by NGINX if that makes any difference.

Antony Dovgal

unread,
Dec 24, 2011, 3:13:05 PM12/24/11
to highloa...@googlegroups.com

Add "umask <value>" to the script that starts FPM in your distro, whatever it is.

--
Wbr,
Antony Dovgal
---
http://pinba.org - realtime profiling for PHP

ominds

unread,
Dec 24, 2011, 11:38:55 PM12/24/11
to highload-php-en
Perfect. Thanks. In case anyone needs this on ubuntu, I modified the
script located in:

/etc/init.d/php5-fpm and changed the following in do_start()

start-stop-daemon --start --quiet ......

to

start-stop-daemon --umask 0007 --start --quiet ......

Can't say I tested it. But I think it will do.

Brian Mercer

unread,
Jan 29, 2012, 4:47:49 PM1/29/12
to highloa...@googlegroups.com


I've tried this on Ubuntu 11.10 and I can't get it to work.

If I'm starting the php-fpm master process with start-stop-daemon --umask 0007 as root, and then that root master process spawns the workers as www-data, are those children supposed to inherit the umask?

Daniel Merriott

unread,
Jan 23, 2014, 5:00:21 PM1/23/14
to highloa...@googlegroups.com
You may be using upstart on ubuntu. If so then see if /etc/init/php5-fpm.conf exists. If it does, edit that file and add `umask 0002` (or whatever umask you like). See http://stackoverflow.com/questions/21248904 for an explanation.
Reply all
Reply to author
Forward
0 new messages