SElinux 练习

练习

.1、安装httpd服务,改变网站的默认主目录为/website,添加SELinux文件标签规则,设置http_sys_content_t到/website及目录下所有文件,使网站可访问

mkdir    /website

vim    /etc/httpd/conf/httpd.conf    (找到文件中DocumentRoot)

blob.png

注释掉/var/…添加新目录保存退出

因为你只建立文件但是  /website 的安全上下文 没有改

两种方法

①找目标,chcon     -R     –reference=/var/www/html     /website

重启服务  centos 6 :service     httpd    restart

               centos 7 :systemctl    restart    httpd

②在文章中就有截图添加安全上下文

 

.2、修改网站端口为9527,增加SELinux端口标签,使网站可访问

blob.png

httpd 默认端口为 80

vim    /etc/httpd/conf/httpd.conf

blob.png

如果修改端口Listen 80 为 9527 会起不来服务httpd

所以 看笔记中的最后添加端口;

先查看semanage    port   –l

semanage port -a -t http_port_t -p tcp 9527

重启服务。

link    x.x.x.x:9527   (此处要加端口号链接)

.3、启用SELinux布尔值,使用户student的家目录可通过http访问

blob.png查看



centos 7     /etc/httpd/conf.d/userdir.conf

centos 6     /etc/httpd/conf/httpd.conf

blob.png把这个UserDir disabled注释 # 掉就启用了

并   吧下面的  userdir    public_html的  # 删掉     wq

blob.png

service    httpd    restart


su – student

ls

mkdir    public_html;cd public_html


echo xxhomeweb > index.html

但是这个  目录的权限只有 student 有权限别人没有访问权限

chmod    711  /home/student

blob.png

blob.png

blob.png

iptables -F

blob.png

网页访问x.x.x.x/~student/











原创文章,作者:Nicolas ZhaoIV,如若转载,请注明出处:http://www.178linux.com/46835

(0)
Nicolas ZhaoIVNicolas ZhaoIV
上一篇 2016-09-19
下一篇 2016-09-19

相关推荐

  • N22- 第五周

    1、显示当前系统上root、fedora或user1用户的默认shell; [root@localhost Packages]# grep -E "^(root|fedora|user1\>)" /etc/passwd | cut -d: -f…

    Linux干货 2016-11-21
  • Stream EDitor ( Blog 6)

    文本流编辑器,行编辑器sed详解

    Linux干货 2017-11-27
  •         linux 文件颜色的含义:         蓝色代表目录         绿色代表可执行文件 &nbs…

    Linux干货 2016-12-05
  • 计算机的组成及其功能简述

    1、计算机的组成 (1)运算器、控制器、寄存器、缓存 –> CPU,Central Processing Unit (2)存储器 –> Memory (3)输入设备 –> Keyboard、Mouse and so on (4)输出设备 –> Displayer and so on (5…

    Linux干货 2016-09-19
  • linux基础学习(数组、字符串变量处理)

    2016-08-22 授课内容: 数组 高级字符串操作 一、数组   变量:存储单个元素的内存空间   数组:存储多个元素的连续的内存空间,相当于多个变量的集合。   数组名和索引   索引:编号从0开始,属于数值索引   bash的数组支持稀疏格式(索引不连续)   …

    Linux干货 2016-08-24

评论列表(1条)

  • 马哥教育
    马哥教育 2016-09-20 13:50

    操作部分缺失?不完整?效果图怎么没有展示出来,同时也没有总结出来此次试验的目的?