本文介绍了如何在Debian上为php5-fpm设置umask?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 php5-fpm nginx 通过端口(而不是套接字)连接。它是股票Debian Jessie与所有包安装通过 apt-get



我正在尝试更改默认umask www-data user php5-fpm 正在使用 0022 0002 允许组写权限。我试过:




  • 编辑 /etc/init.d/php5-fpm init脚本,并将 - umask 0002 添加到 start-stop-daemon 调用,但被忽略; / li>
  • umask 0002 添加到 /var/www/.profile / var / www www-data 用户的主目录,但没有帮助(我没有惊讶)

  • 我没有使用 upstart so 不适合我。



此外,无论我尝试了什么,命令 sudo -u www-data bash -c umask 总是返回 0022

解决方案

我可以通过编辑单位来设置 php5-fpm 服务的umask。服务文件,建议和。 Debian 8的完整和工作的解决方案是:


  1. 手动编辑 / etc / systemd / system / user.target.wants / php5-fpm.service 文件,并添加 UMask = 0002 行内 [服务] code> section。

  2. 运行命令 systemctl守护程序重新加载

  3. 运行命令 systemctl restart php5-fpm.service

现在服务文件看起来像这样:

  [单位] 
描述= PHP FastCGI流程管理器
之后= network.target

[服务]
类型=通知
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
;添加到设置umask为PHP创建的文件
UMask = 0002

[安装]
WantedBy =多用户目标
/ pre>

请注意:


  1. 您不能使用 systemctl编辑php5-fpm.service 命令作为编辑选项在 systemctl 版本218,但Debian 8附带版本215.

  2. 添加 *。conf 文件,建议在此不适合我,但也许我搞砸了一些东西(欢迎给予评论,因为编辑单元文件不是我觉得舒服的东西)。


I'm running php5-fpm with nginx connected via port (not socket). It's stock Debian Jessie with all packages installed via apt-get.

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:

  • editing /etc/init.d/php5-fpm init script and adding --umask 0002 to the start-stop-daemon call, but it was ignored;
  • adding umask 0002 to /var/www/.profile as /var/www is a home directory for www-data user, but it didn't help (I'm not surprised).
  • I'm not using upstart so this solution is not for me.

Also, no matter what I've tried, the command sudo -u www-data bash -c umask always returns 0022.

解决方案

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:

  1. Manually edit /etc/systemd/system/multi-user.target.wants/php5-fpm.service file and add UMask=0002 line inside [Service] section.
  2. Run command systemctl daemon-reload
  3. 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

Note that:

  1. You can not use systemctl edit php5-fpm.service command as edit option was introduced in systemctl version 218 but Debian 8 ships with version 215.
  2. 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 23:45