[英]How to set umask for www-data user?
I am currently running Apache/2.4.10 (Debian Jessie) with PHP 7.0.6 fpm我目前正在使用 PHP 7.0.6 fpm 运行 Apache/2.4.10 (Debian Jessie)
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.现在我需要将 umask 0002 添加到php-fpm.conf
所有要点,以便www-data
用户将创建具有rw-rw-r
权限的文件。
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.手动编辑/etc/systemd/system/multi-user.target.wants/ php7.0-fpm.service
文件并在 [Service] 部分添加UMask=0002
行。
Previously, it was like this.以前,它是这样的。
then然后
Run command systemctl daemon-reload
运行命令systemctl daemon-reload
then然后
Run command systemctl restart php7.0-fpm.service运行命令 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.注意:您不能使用systemctl
edit php7.0-fpm.service 命令,因为systemctl
版本 218 中引入了编辑选项,但 Debian 8 附带版本 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. sudo -u www-data touch foo
将触摸文件foo
就好像网络服务器在没有 PHP 的情况下完成了它。 Thus, the webservers process umask will be used, not the one set in PHP-FPM.因此,将使用网络服务器进程 umask,而不是 PHP-FPM 中设置的进程。 To change the webservers process umask, you'll need to edit the envvars
file in /etc/apache2
(for Debian based systems).要更改网络服务器进程 umask,您需要编辑/etc/apache2
的envvars
文件(对于基于 Debian 的系统)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.