在/etc/selinux/config中selinux默认是打开的,改为disabled是关闭
创建SELinux策略
安装semanage命令:
# yum install -y policycoreutils-python setroubleshooting
- 给
/websites目录以及所有子目录和文件设置httpd_sys_content_t上下文策略
#semanage fcontext -a -t httpd_sys_content_t "/websites(/.*)?"
- 给日志目录设置
httpd_log_t上下文策略权限
#semanage fcontext -a -t httpd_log_t "/websites/logs(/.*)?"
- 给缓存目录设置
httpd_cache_t上下文策略权限
#semanage fcontext -a -t httpd_cache_t "/websites/cache(/.*)?"
- 使其生效
#restorecon -Rv /websites
可以用ls -lz查看