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

Mic*_*ael 2 apache selinux

我在/ var/www/html/ict中有一个挂载目录.允许用户权限很好但仍然通过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)
Run Code Online (Sandbox Code Playgroud)

Reu*_*ben 5

这不是简单地提供链接,而是完全撕掉该链接的内容,而不是简单地说.

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

yum install -y policycoreutils-python
Run Code Online (Sandbox Code Playgroud)

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

在DocumentRoot之外创建作为应用程序一部分的只读区域的策略

semanage fcontext -a -t httpd_sys_content_t "/webapps(/.*)?"
Run Code Online (Sandbox Code Playgroud)

创建记录目录的策略

semanage fcontext -a -t httpd_log_t "/webapps/logs(/.*)?"
Run Code Online (Sandbox Code Playgroud)

为缓存目录创建策略

semanage fcontext -a -t httpd_cache_t "/webapps/cache(/.*)?"
Run Code Online (Sandbox Code Playgroud)

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

semanage fcontext -a -t httpd_sys_rw_content_t "/webapps/app1/public_html/uploads(/.*)?"
Run Code Online (Sandbox Code Playgroud)

使用restorecon命令应用策略

restorecon -Rv /webapps
Run Code Online (Sandbox Code Playgroud)

已应用验证策略

ls -lZ /webapps
Run Code Online (Sandbox Code Playgroud)

简而言之就是这样.然而,原始文章更好阅读.