Selinux 拒绝写入 /var/www/tmp,即使上下文是 httpd_sys_rw_content_t

Selinux denying writing to /var/www/tmp even though the context is httpd_sys_rw_content_t

问题:

httpd 无法写入 /var/www/tmp,因为它被 SELinux 阻止了。

描述: 我用来从我的网站下载报告的 PDF 报告库抛出 'Permission Denied' 错误,因为它无法写入 /var/www/tmp.我已将 phptmp 文件夹位置设置为 /var/www/tmp/var/www/tmpapache 所有。此外,其上下文已设置为 httpd_sys_rw_content_t。仍然 httpd 无法写入此目录。

我错过了什么?

我已经使用以下命令设置了上下文和权限。

chown -R apache:apache /var/www/tmp semanage fcontext -a httpd_sys_rw_content_t "/var/www/tmp(/.*)?"

可能出了什么问题?请注意,我不想禁用 SELinux。

我认为应该在 semanage 命令中添加 -t 标志来指定类型。之后使用 restorecon -v

应用更改