配置SELinux访问,以便Apache可以访问已安装的目录

时间:2014-03-23 21:42:10

标签: apache selinux

我在/ var / www / html / ict中有一个来自home的挂载目录。允许用户权限很好但仍然通过Web浏览器我收到403错误。

SELinux我怀疑不允许来自其他位置的文件和目录。你能帮我添加相关的权限,以便修复。

审核文件中的错误日志:

    type=AVC msg=audit(1395610534.041:179195): avc:  denied  { search } for  pid=18370 comm="httpd" name="upload" dev=dm-0 ino=2506938 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1395610534.041:179195): arch=c000003e syscall=4 success=no exit=-13 a0=7ffb5f863bc8 a1=7fff80a374c0 a2=7fff80a374c0 a3=0 items=0 ppid=3075 pid=18370 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1395610534.043:179196): avc:  denied  { getattr } for  pid=18370 comm="httpd" path="/var/www/html/ict/farengine" dev=dm-0 ino=2506938 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
type=SYSCALL msg=audit(1395610534.043:179196): arch=c000003e syscall=6 success=no exit=-13 a0=7ffb5f863cb0 a1=7fff80a374c0 a2=7fff80a374c0 a3=1 items=0 ppid=3075 pid=18370 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)

2 个答案:

答案 0 :(得分:5)

不是简单地提供一个链接,而是完全没有删除该链接的内容,这里就是失败了。

安装包含SEMANAGE的policycoreutils-python,以允许设置允许Apache在DocumentRoot之外读取或读/写区域的策略。

yum install -y policycoreutils-python

文章还提到了一个故障排除包,但我的机器无法找到它。

为DocumentRoot之外的只读区域创建策略

semanage fcontext -a -t httpd_sys_content_t "/webapps(/.*)?"

创建记录目录的策略

semanage fcontext -a -t httpd_log_t "/webapps/logs(/.*)?"

为缓存目录创建策略

semanage fcontext -a -t httpd_cache_t "/webapps/cache(/.*)?"

为DocumentRoot之外的读/写区域创建策略

semanage fcontext -a -t httpd_sys_rw_content_t "/webapps/app1/public_html/uploads(/.*)?"

使用restorecon命令

应用策略
restorecon -Rv /webapps

已应用验证政策

ls -lZ /webapps

简而言之就是这样。但是original article更好看。

答案 1 :(得分:1)

如果您使用CentOS SELinux 试试:

sudo restorecon -r /var/www/html

查看更多:https://www.centos.org/forums/viewtopic.php?t=6834#p31548

相关问题