3.2 httpd配置文件及参数-3.2.2 SELinux 安全系统

1.SELinux服务有3种配置模式

enforcing :强制启用安全策略模式,将拦截服务的不合法请求。
permissive :遇到服务越权访问时,只发出警告而不强制拦截。
disabled :对于越权的行为不警告也不拦截。

2.修改SELinux服务主配置文件中定义的默认状态,修改为enforcing

[root@dsrw ~]# vim /etc/selinux/config
SELINUX=enforcing

3.getenforce命令获得当前SELinux服务的运行模式

[root@dsrw ~]# getenforce
Enforcing

4.setenforce [0|1]命令修改SELinux当前的运行模式(0为禁用,1为启用)

[root@dsrw ~]# setenforce 0
[root@dsrw ~]# getenforce
Permissive
图片[1]-3.2 httpd配置文件及参数-3.2.2 SELinux 安全系统-大赛人网
图3-4 显示网页内容

5.服务恢复到强制启用安全策略模式修改为enforcing状态

[root@dsrw ~]# setenforce 1
[root@dsrw ~]# getenforce
Enforcing

6.查看原始网站数据的保存目录与当前网站数据的保存目录是否拥有不同的SELinux安全上下文值

[root@dsrw ~]# ls -Zd /var/www/html
system_u:object_r:httpd_sys_content_t:s0 /var/www/html
[root@dsrw ~]# ls -Zd /home/www
unconfined_u:object_r:user_home_dir_t:s0 /home/www

7.semanage命令管理SELinux的策略,语法格式为“semanage [参数] [文件]”

semanage 命令中的常用参数以及作用
-l:查询
-a:添加
-m:修改
-d:删除
7.向非默认网站数据目录中新添加SELinux安全上下文,并立即生效
[root@dsrw ~]# semanage fcontext -a -t httpd_sys_content_t /home/www
[root@dsrw ~]# semanage fcontext -a -t httpd_sys_content_t /home/www/*
[root@dsrw ~]# restorecon -Rv /home/www/
Relabeled /home/www from unconfined_u:object_r:user_home_dir_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /home/www/index.html from unconfined_u:object_r:user_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
图片[2]-3.2 httpd配置文件及参数-3.2.2 SELinux 安全系统-大赛人网
图3-5 正常显示
© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称

    请登录后查看评论内容