SELinux个人学习:[1]解决web网站无法访问

 时间:2024-10-14 02:22:12

1、setroubleshoot用于把SELinux 的错误讯息与克服方法记录到 /var/log/messages 与 /var/log/setroubleshoot/* 里头,所以一定要启动该服务。所以我们先来安装。输入一下命令安装。# yum install setroubleshoot setroubleshoot-server

SELinux个人学习:[1]解决web网站无法访问

2、安装之后,要重新启动 auditd,否则 setroubleshootd 的功能不会被启动的输入以下命令# service auditd restart

SELinux个人学习:[1]解决web网站无法访问

3、在浏览器输入网页地址。显示一下信息,这个时候错误的信息就被记录了。ForbiddenYou don't have permission to access /index.html on this server.

SELinux个人学习:[1]解决web网站无法访问

4、输入一下命令。来查看错误信息# cat /var/log/message衡痕贤伎s | grep setroubleshootApr 21 23多唉捋胝:34:37 centos setroubleshoot: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html. For complete SELinux messages. run sealert -l 47d2c8e2-308b-4931-ae63-88bb4f518155最重要的是sealert -l 47d2c8e2-308b-4931-ae63-88bb4f518155

SELinux个人学习:[1]解决web网站无法访问

5、输入之前找到的信息sealert -l 47d2c8e2-308b-49补朱锚卦31-ae63-88bb4f518155显示以下内容SELinux is preventing /usr/sbin/httpd from getattr access on the 文件 /var/www/html/index.html.***** 插件 restorecon (99.5 置信度) 建议 ******************************************If 您想要修复标签。/var/www/html/index.html 默认标签应为 httpd_sys_content_t。Then 您可以运行 restorecon。Do# /sbin/restorecon -v /var/www/html/index.html***** 插件 catchall (1.49 置信度) 建议 ********************************************If 您确定应默认允许 httpd getattr 访问 index.html file。Then 您应该将这个情况作为 bug 报告。您可以生成本地策略模块允许这个访问。Do请执行以下命令此时允许这个访问:# grep httpd /var/log/audit/audit.log | audit2allow -M mypol# semodule -i mypol.pp

SELinux个人学习:[1]解决web网站无法访问

6、从上面的内容,就已经提示你解决的方法。If 您想要修复标签。/var/www/html/index.html 默认标签应为 httpd_sys_content_t。Then 您可以运行 restorecon。Do# /sbin/restorecon -v /var/www/html/index.html所以输入# /sbin/restorecon -v /var/www/html/index.html网站可以正常浏览了。

  • 如何购买印度波立维
  • 2019春节燃放烟花爆竹注意事项
  • 游戏the curse 详细攻略
  • 原神怎么去清籁岛
  • 热门搜索
    消防安全手抄报大全 国防教育手抄报资料 庆元旦手抄报内容 走进大自然手抄报 保护环境手抄报大全 名著阅读手抄报 清明节手抄报内容资料 运动会手抄报图片 成语手抄报 反对邪教手抄报内容