简体   繁体   English

Nginx / php-fpm umask设置

[英]Nginx/php-fpm umask setting

When I was using apache2 server, setting default umask in /etc/apache2/envvars to 0002 used to solve all my permissions problems. 当我使用apache2服务器时,将/ etc / apache2 / envvars中的默认umask设置为0002用于解决我的所有权限问题。 Now that I am trying to setup nginx/php-fpm, I have come across the same problems when files are created with improper permissions. 现在我正在尝试设置nginx / php-fpm,当使用不正确的权限创建文件时,我遇到了同样的问题。

Is there umask setting in nginx or php-fpm? 在nginx或php-fpm中是否有umask设置?

Taken from the other answer's linked question: 取自其他答案的相关问题:

if you use systemd [ie Ubuntu 16.04], then edit /lib/systemd/system/php5-fpm.service 如果你使用systemd [即Ubuntu 16.04],那么编辑/lib/systemd/system/php5-fpm.service
And edit chapter "Service": 并编辑“服务”章节:

[Service]
UMask=0002

Thanks to Blossoming_Flower's answer and an answer on unix.stackechange ... 感谢Blossoming_Flower的回答unix.stackechange上答案 ......

The best way seems to do as Blossoming _Flower says, but do it with an override file instead of editing a system file that may get replaced by a reinstall/upgrade by your distribution. 最好的方式似乎是像Blossoming _Flower所说的那样,但是使用覆盖文件而不是编辑系统文件,可能会被您的发行版重新安装/升级所取代。

To do this you do (I'm on php 7.0 but adjust for your version) 要做到这一点你做(我在PHP 7.0上,但调整您的版本)

systemctl edit php7.0-fpm.service

which will automatically create (or edit if already exists) a file at /etc/systemd/system/php7.0-fpm.service.d/override.conf . 它将在/etc/systemd/system/php7.0-fpm.service.d/override.conf自动创建(或编辑,如果已存在)文件。

You can put Blossoming_Flower's suggested content on its own in that file. 您可以在该文件中单独放置Blossoming_Flower的建议内容。 Systemd will then overwrite the distribution's settings with this one, in effect adding a umask setting. 然后,Systemd将使用此设置覆盖分发的设置,实际上添加了umask设置。

Then just systemctl daemon-reload && systemctl restart php7.0-fpm and you're done. 然后只需要systemctl daemon-reload && systemctl restart php7.0-fpm就可以了。

I managed to resolve this for myself by adding umask 0002 to /etc/init/php-fpm.conf ( not /etc/init.d/php-fpm ). 我设法通过将umask 0002添加到/etc/init/php-fpm.conf而不是 /etc/init.d/php-fpm )来解决这个问题。 See How to trace where php5-fpm umask settings are coming from on ubuntu for an explanation. 有关说明,请参阅如何在ubuntu上跟踪php5-fpm umask设置的来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM