关于 selinux 规则
·
1. 查看selinux状态
SELinux的状态:
-
enforcing:强制,每个受限的进程都必然受限
-
permissive:允许,每个受限的进程违规操作不会被禁止,但会被记录于审计日志
-
disabled:禁用
相关命令:
-
getenforce: 获取selinux当前状态
-
sestatus :查看selinux状态
-
setenforce 0|1 0设置为 permissive 1设置为 enforcing
[root@localhost html]#getenforce
Enforcing
如果没有开启可以使用以下命令开启
[root@localhost html]#setenforce 1
永久开启需要修改 此处文件 /etc/selinux/config
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing

开启selinux
安装此包,使用 seinfo 命令


查看文件类型

测试:
可以看到 那是因为这个模块 httpd_sys_content_t

如果修改文件类型


访问不到了

还有控制端口的


添加一个端口

他报错,不让重启httpd服务
添加以下端口模块,才可以使用
重启成功

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)