【发布时间】:2016-09-02 10:42:55
【问题描述】:
我目前正在使用 PHP 7.0.6 fpm 运行 Apache/2.4.10 (Debian Jessie)
现在我需要将 umask 0002 添加到 php-fpm.conf 中,以便 www-data 用户将创建具有 rw-rw-r 权限的文件。
【问题讨论】:
我目前正在使用 PHP 7.0.6 fpm 运行 Apache/2.4.10 (Debian Jessie)
现在我需要将 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 命令,因为 systemctl 版本 218 中引入了编辑选项,但 Debian 8 附带版本 215。
【讨论】:
sudo -u www-data touch foo 并且仍在使用旧的 umask。欢迎提出建议...
关于威廉·特瑞尔的评论:
sudo -u www-data touch foo 将访问文件 foo,就好像网络服务器在没有 PHP 的情况下完成了它一样。因此,将使用网络服务器进程 umask,而不是 PHP-FPM 中的设置。要更改网络服务器进程 umask,您需要编辑 /etc/apache2 中的 envvars 文件(对于基于 Debian 的系统)。
【讨论】: