2.7.2. 为 Apache HTTP 服务器归档安装安装 SELinux 策略
在本发行版本中,存档软件包提供 SELinux 策略。.postinstall.selinux 文件包含在 root Apache HTTP Server 文件夹中。如果需要,您可以运行 .postinstall.selinux 脚本。
默认情况下,Apache HTTP 服务器提供的 SELinux 策略不活跃,且 Apache HTTP 服务器进程在 unconfined_t 域中运行。这个域不受限制进程。如果您选择不启用提供的 SELinux 策略,请限制 apache 用户的文件访问权限,以便 apache 用户只能访问 Apache HTTP 服务器运行时所需的文件和目录。
流程
安装
selinux-policy-devel软件包:yum install -y selinux-policy-devel运行
.postinstall.selinux脚本:cd <httpd_home> sh .postinstall.selinux进行并安装 SELinux 模块:
cd <httpd_home>/selinux/ make -f /usr/share/selinux/devel/Makefile semodule -i jbcs-httpd24-httpd.pp为 Apache HTTP 服务器应用 SELinux 上下文:
restorecon -r <httpd_home>为 Apache HTTP 服务器所需端口添加访问权限:
semanage port -a -t http_port_t -p tcp 6666 semanage port -a -t http_port_t -p udp 23364启动 Apache HTTP 服务器服务:
<httpd_home>/sbin/apachectl start检查预期
httpd_t正在运行的进程的上下文:$ ps -eZ | grep httpd | head -n1 unconfined_u:unconfined_r:httpd_t:s0-s0:c0.c1023 2864 ? 00:00:00 httpd验证 httpd 目录的上下文。例如:
ls -lZ <httpd_home>/logs/