Darius S Darius S - 1 year ago 190
PHP Question

How to set umask for www-data user?

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

, so that
user will create files with

Answer Source

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


Run command systemctl daemon-reload


Run command systemctl restart php7.0-fpm.service

Now the service file looks like this:

Description = The PHP FastCGI Process Manager
After = network.target

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

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download