我正在php5-fpm
与nginx
通过端口(不是套接字)连接。它通过apt-get
安装了所有软件包的Debian Jessie。
我尝试更改php5-fpm
正在使用{-1}}到0022
的www-data用户的默认umask,以允许群组写入权限。我试过了:
0002
初始化脚本并将/etc/init.d/php5-fpm
添加到--umask 0002
来电,但却被忽略了; start-stop-daemon
添加到umask 0002
/var/www/.profile
是/var/www
用户的主目录,但它没有帮助(我并不感到惊讶) www-data
因此this solution不适合我。此外,无论我尝试过什么,命令upstart
始终会返回sudo -u www-data bash -c umask
。
答案 0 :(得分:4)
我可以通过按照建议here和here编辑php5-fpm
文件来为unit.service
服务设置umask。 Debian 8的完整且可行的解决方案是:
/etc/systemd/system/multi-user.target.wants/php5-fpm.service
文件,并在UMask=0002
部分添加[Service]
行。systemctl daemon-reload
systemctl restart php5-fpm.service
现在服务文件如下所示:
[Unit]
Description = The PHP FastCGI Process Manager
After = network.target
[Service]
Type = notify
PIDFile = /var/run/php5-fpm.pid
ExecStartPre = /usr/lib/php5/php5-fpm-checkconf
ExecStart = /usr/sbin/php5-fpm --nodaemonize --fpm-config /etc/php5/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 php5-fpm.service
命令,edit
版本218中引入了systemctl
选项,但Debian 8附带版本215. *.conf
文件对我来说不起作用,但也许我搞砸了一些事情(欢迎评论,因为编辑单元文件不是我觉得舒服的东西用)。