问题原文
原帖链接 · coolnodje · CC BY-SA 3.0
I want to make sure members of the adm groups can read all logs, and the php-fpm process makes an exception as it logs php5-fpm.log under root:root and u=r+w
I can't find a way to achieve this. I've considered using syslog.facility directives but I'd rather keep a dedicated log file.
已采纳解答
原帖链接 · Esa Jokinen · CC BY-SA 4.0
You should read more carefully the manual on PHP FPM Configuration php-fpm.conf directives:
- The
syslog.facilitydirective only controls the facility type and is by default set todaemon. This doesn't affect the location. Non-normative syslog facilities are defined in RFC 5424, 6.2.1. As you can see, facilities 16-23 are for local use and you could dedicate one for PHP FPM. - The correct directive for sending log to syslogd instead of local file is
error_log syslog, while the default value is#INSTALL_PREFIX#/log/php-fpm.log. - Another important directive here is
syslog.ident php-fpm(that is the default value).
On configuration level there's nothing about file permissions. You'd have to get on the source code level to figure out how it's actually done. Some advice changing log file permissions on an init script.
One Logrotate to rule them all
File permissions can be controlled in logrotate configuration, which also has create directive.
/var/log/php-fpm.log {
create 0640 root adm
}
Syslogd & dedicated facility
Using the Syslogd enables configuring all file locations on the same syslog.conf. It is still possible to configure syslogd to use separate log file for PHP FPM by the dedicated facility, e.g. local4:
# /etc/syslog.conf
local4.* /var/log/php-fpm.log
Rsyslog filters
If you're using rsyslogd, you can filter the PHP-FPM's syslog.ident prepended to every message:
# /etc/rsyslog.conf
:syslogtag, isequal, "php-fpm" /var/log/php-fpm.log
:syslogtag, isequal, "php-fpm" ~
With rsyslogd, file permissions are also set in the rsyslog.conf:
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
