centos

SELinux策略如何在CentOS中应用

小樊
44
2025-08-10 11:15:23
栏目: 智能运维

在CentOS中应用SELinux策略,首先要安装相关软件包,可使用命令sudo yum install -y policycoreutils selinux-policy selinux-policy-targeted。然后通过编辑/etc/selinux/config文件设置模式,如将SELINUX=disabled改为SELINUX=enforcing来启用强制模式,需重启系统生效。也可使用setenforce命令临时切换模式。

对于特定服务策略配置,以Apache为例,可安装Apache后,用sudo chcon -R --reference=/var/www/html /path/to/your/web/directory设置文件安全上下文。还可使用semanage命令管理策略模块,如sudo semanage port -a -t http_port_t -p tcp 80允许HTTP服务访问网络。

0
看了该问题的人还看了