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.
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.
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.
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).