如何为 www-data 用户设置 umask?
How to set umask for www-data user?
我目前 运行 Apache/2.4.10 (Debian Jessie) PHP 7.0.6 fpm
现在我需要将 umask 0002 添加到 php-fpm.conf
中的所有要点,以便 www-data
用户将创建具有 rw-rw-r
权限的文件。
我希望这会奏效,请尝试这种方式
手动编辑 /etc/systemd/system/multi-user.target.wants/ php7.0-fpm.service
文件并在 [Service] 部分中添加 UMask=0002
行。
以前是这样的
然后
运行 命令 systemctl daemon-reload
然后
运行 命令 systemctl restart php7.0-fpm.service
现在服务文件如下所示:
[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
注意: 您不能使用 systemctl
edit php7.0-fpm.service 命令,因为 [=14] 中引入了编辑选项=] 版本 218 但 Debian 8 附带版本 215.
关于 William Turrell 的评论:
A sudo -u www-data touch foo
将接触文件 foo
,就好像网络服务器在没有 PHP 的情况下完成了它一样。因此,将使用网络服务器进程 umask,而不是 PHP-FPM 中设置的那个。要更改网络服务器进程 umask,您需要编辑 /etc/apache2
中的 envvars
文件(对于基于 Debian 的系统)。
我目前 运行 Apache/2.4.10 (Debian Jessie) PHP 7.0.6 fpm
现在我需要将 umask 0002 添加到 php-fpm.conf
中的所有要点,以便 www-data
用户将创建具有 rw-rw-r
权限的文件。
我希望这会奏效,请尝试这种方式
手动编辑 /etc/systemd/system/multi-user.target.wants/ php7.0-fpm.service
文件并在 [Service] 部分中添加 UMask=0002
行。
以前是这样的
然后
运行 命令 systemctl daemon-reload
然后
运行 命令 systemctl restart php7.0-fpm.service
现在服务文件如下所示:
[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
注意: 您不能使用 systemctl
edit php7.0-fpm.service 命令,因为 [=14] 中引入了编辑选项=] 版本 218 但 Debian 8 附带版本 215.
关于 William Turrell 的评论:
A sudo -u www-data touch foo
将接触文件 foo
,就好像网络服务器在没有 PHP 的情况下完成了它一样。因此,将使用网络服务器进程 umask,而不是 PHP-FPM 中设置的那个。要更改网络服务器进程 umask,您需要编辑 /etc/apache2
中的 envvars
文件(对于基于 Debian 的系统)。