SELinux
yum install -y httpd
/etc/init.d/httpd start
vim /etc/sysconfig/selinux
將disabled改爲permissive 然後一定要reboot之後才生效
這個實驗一定要開啓httpd 同時selinux一定不能是disabled
[root@server7 ~]# mkdir /happy
[root@server7 ~]# touch /happy/zhouqi
[root@server7 ~]# ls -Zd /happy/
drwxr-xr-x. root root system_u:object_r:default_t:s0 /happy/
[root@server7 ~]# ls -Z /happy/
-rw-r--r--. root root system_u:object_r:default_t:s0 zhouqi
yum install -y policycoreutils.x86_64 policycoreutils-python.x86_64
semanage命令需要policycoreutils-python.x86_64這個軟件包是這個軟件包的一部分
restorecon命令需要policycoreutils.x86_64這個軟件包 是這個軟件包的一部分
[root@server7 ~]# semanage fcontext -a -f "" -t httpd_sys_content_t '/happy(/.*)?'[root@server7 ~]# restorecon -RFvv /happy/
restorecon reset /happy context system_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
restorecon reset /happy/zhouqi context system_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
[root@server7 ~]# ls -Zd /happy/
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /happy/
[root@server7 ~]# ls -Z /happy/
-rw-r--r--. root root system_u:object_r:httpd_sys_content_t:s0 zhouqi
好了 現在這個目錄有標誌httpd_sys_content_t了
########## 管理SELinux布爾值###########
[root@server7 ~]# getsebool -a 用於顯示布爾值
abrt_anon_write --> off
abrt_handle_event --> off
........
xserver_object_manager --> off
zabbix_can_network --> off
[root@server7 ~]# getsebool httpd_enable_homedirs
httpd_enable_homedirs --> off
[root@server7 ~]# setsebool httpd_enable_homedirs on
setsebool 用於修改布爾值 getsebool 用於顯示布爾值
[root@server7 ~]# semanage boolean -l |grep httpd_enable_homedirs
httpd_enable_homedirs (on , off) Allow httpd to read home directories ##semanage boolean -l 用於顯示布爾值是否永久
[root@server7 ~]# getsebool httpd_enable_homedirs
httpd_enable_homedirs --> on
[root@server7 ~]# setsebool -P httpd_enable_homedirs on
### setsebool -P 修改SELinux策略,以永久保留修改
[root@server7 ~]# semanage boolean -l |grep httpd_enable_homedirs
httpd_enable_homedirs (on , on) Allow httpd to read home directories
##### semanage boolean -l 用於顯示布爾值是否永久