问题描述
我正在运行 php5-fpm
,其中 nginx
通过端口(不是套接字)连接.它是 Debian Jessie 的库存,所有软件包都通过 apt-get
安装.
I'm running php5-fpm
with nginx
connected via port (not socket). It's stock Debian Jessie with all packages installed via apt-get
.
我正在尝试将 php5-fpm
使用的 www-data 用户的默认 umask 从 0022
更改为 0002
以允许组写权限.我试过了:
I'm trying to change default umask for www-data user that php5-fpm
is using from 0022
to 0002
to allow group write permissions. I've tried:
- 编辑
/etc/init.d/php5-fpm
init 脚本并将--umask 0002
添加到start-stop-daemon
调用,但被忽略; - 将
umask 0002
添加到/var/www/.profile
作为/var/www
是www- 的主目录data
用户,但它没有帮助(我并不感到惊讶). - 我没有使用
upstart
所以这个解决方案不适合我.
- editing
/etc/init.d/php5-fpm
init script and adding--umask 0002
to thestart-stop-daemon
call, but it was ignored; - adding
umask 0002
to/var/www/.profile
as/var/www
is a home directory forwww-data
user, but it didn't help (I'm not surprised). - I'm not using
upstart
so this solution is not for me.
此外,无论我尝试过什么,命令 sudo -u www-data bash -c umask
总是返回 0022
.
Also, no matter what I've tried, the command sudo -u www-data bash -c umask
always returns 0022
.
推荐答案
我能够通过编辑 unit.service
文件为 php5-fpm
服务设置 umask正如建议的此处和此处.Debian 8 的完整且有效的解决方案是这样的:
I was able to set the umask for php5-fpm
service by editing it's unit.service
file as suggested here and here. The complete and working solution for Debian 8 is this:
- 手动编辑
/etc/systemd/system/multi-user.target.wants/php5-fpm.service
文件并在中添加
部分.UMask=0002
行[服务] - 运行命令
systemctl daemon-reload
- 运行命令
systemctl restart php5-fpm.service
- Manually edit
/etc/systemd/system/multi-user.target.wants/php5-fpm.service
file and addUMask=0002
line inside[Service]
section. - Run command
systemctl daemon-reload
- Run command
systemctl restart php5-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/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
选项是在systemctl
版本 218 中引入的,但 Debian 8 附带版本 215. - 按照对此答案的评论中的建议添加
*.conf
文件不适用于我,但也许我搞砸了一些东西(欢迎对此发表评论,因为我不喜欢编辑单元文件).
- You can not use
systemctl edit php5-fpm.service
command asedit
option was introduced insystemctl
version 218 but Debian 8 ships with version 215. - Adding
*.conf
file as suggested in comments for this answer did not work for me, but maybe I messed up something (comments are welcome for this as editing unit file is not something that I feel comfortable with).
这篇关于如何在 Debian 上为 php5-fpm 设置 umask?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!