selinux firewalld httpd 等后续更新

getenforce -------查看selinux的模式

selinux的配置模式修改

永久修改;

------ll /etc/sysconfig/selinux /etc/selinux/sonfig  查看配置文件和系统日志

------vim /etc/selinux/config

       SELINUX=disabled关闭 / permissive启用但不执行 / enforcing启用及执行

------reboot

部署httpd服务

要求:httpd需要读取var/www/html/index.html

-----systemctl stat httpd 开启次服务

-----echo redhat >>index/html

-----mv index.html var/www/html/

-----curl http://localhost

开启selinux

------setenforce 1

-------curl /http://localhost -l

-------ls -ldZ /var/www/html/index.html    admin_home_t的安全性上下文

-------ps -elfZ | grep httpd  进程的安全上下文

修改安全性上下文


第一种方法,还原默认值又变回默认值:

-----chocn -t httpd_sys_content_t /test

------chcon --reference=/tmp /test 以/tmp为参照修改/test目录为/tmp

------ll -ldZ /test 修改后查看test

------ll -ldZ /tmp 

------restorecon -Rv /test 还原默认值

第二种方法:推荐

-----semanage fcontext -a -t httpd_sys_content_t "/test(/.*)?"修改/test及其子目录下的默认安全性上下文为http_sys_content_t

-----ll -ldZ /test  

-----restorecon -Rv /test  还原默认值

-----semanage fcontext -l | grep test

firewalld基础命令

------systemctl stop firewalld  关闭

------systemctl start firewalld  启动

------systemctl enabled firewalld 开机自动启动

------firewall-cmd --state 查看状态  

------systemctl status firewalld  查看配置

-----firewall-cmd --reload不影响现有服务及用户连接

----ps -ef | grep firewalld 查看进程

-----firewall-cmd --get-zones 查看所有zone

-----firewall-cmd --get-default-zone 查看默认zone

-----fierwall-cmd --list-all 查看当前zone

-----firewall-cmd --list-all --zone=work 查看zone状态

----firewall-cmd --list-service 查看当前zone默许哪些服务

----ls /usr/lib/firewalld/services/ 查看支持哪些服务

----firewall-cmd --list-ports 查看当前端口状态

------firewall-cmd --query-port=80/tcp 查看具体端口开发状态

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值