1

I am currently running Apache/2.4.10 (Debian Jessie) with PHP 7.0.6 fpm

All points that now I need to add umask 0002 into php-fpm.conf, so that www-data user will create files with rw-rw-r permissions.

techraf
  • 64,883
  • 27
  • 193
  • 198
Darius S
  • 35
  • 1
  • 6

2 Answers2

0

I hope this will work, Please try this way

Manually edit /etc/systemd/system/multi-user.target.wants/ php7.0-fpm.service file and add UMask=0002 line inside [Service] section.

Previously, it was like this.

enter image description here

then

Run command systemctl daemon-reload

then

Run command systemctl restart php7.0-fpm.service

Now the service file looks like this:

[Unit]
Description = The PHP FastCGI Process Manager
After = network.target

[Service]
Type = notify
PIDFile = /var/run/php/php7.0-fpm.pid 
ExecStartPre = /usr/lib/php/php7.0-fpm-checkconf
ExecStart = /usr/sbin/php-fpm7.0 --nodaemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf
ExecReload = /bin/kill -USR2 $MAINPID
; Added to set umask for files created by PHP
UMask = 0002

[Install]
WantedBy = multi-user.target

NB : You can not use systemctl edit php7.0-fpm.service command as edit option was introduced in systemctl version 218 but Debian 8 ships with version 215.

Renjith V R
  • 2,981
  • 2
  • 22
  • 32
  • 1
    Thanks for your answer, but i need to do that via only config file. I can't edit service. – Darius S Sep 02 '16 at 12:41
  • FWIW this didn't seem to help me with Debian 8.9 - specifically I ran `sudo -u www-data touch foo` after doing all the steps and the old umask was still being used. Suggestions welcome... – William Turrell Jul 24 '17 at 15:07
0

Regarding the comment of William Turrell:

A sudo -u www-data touch foo will touch the file foo as if the webserver has done it without PHP. Thus, the webservers process umask will be used, not the one set in PHP-FPM. To change the webservers process umask, you'll need to edit the envvars file in /etc/apache2 (for Debian based systems).

Adspectus
  • 11
  • 3