为什么 httpd 拒绝 error_log 的权限?

Why is httpd throwing permissions denied for error_log?

我创建了一个新目录:

mkdir -p /webapps/logs

然后我设置上下文和权限,以便 apache 可以写入:

chcon -Rv --type=httpd_sys_content_t /webapps/logs
chmod 2770 -Rv /webapps
chgrp -Rv webadmins /webapps

Apache 是该组的成员:

grep webadmins /etc/group
#Prints out: webadmins:x:1002:apache

而 webadmins 是目录的所属组:

stat -c "%U %G" /webapps/logs
#Prints out: root webadmins

那么,为什么在 /webapps/logs/error_log 上启动 httpd 时我的权限被拒绝?

根据 this,我需要将 SELinux 上下文更改为 "rw":

chcon -Rv --type=httpd_sys_rw_content_t /webapps/logs

这解决了问题。