在CentOS上部署SELinux可按以下步骤进行:
uname -r
命令检查内核版本是否支持SELinux。sudo yum install policycoreutils selinux-policy-targeted
安装相关软件包。/etc/selinux/config
文件,将SELINUX
设置为enforcing
(强制模式)、permissive
(宽容模式)或disabled
(禁用模式),保存后重启系统生效。semanage
命令管理策略模块,如sudo semanage port -a -t http_port_t -p tcp 80
允许HTTP服务访问网络;用chcon
命令更改文件或目录的安全上下文,如sudo chcon -t httpd_sys_content_t /var/www/html
。sestatus
命令查看状态,查看日志可使用sudo ausearch -m avc -ts recent
等命令。