一般安装linux课程时都把SELinux与iptables安排在后面,使初学者配置linux服务器时不成功,却没有头绪,那是因为在RedHat 中默认开启了防火墙,SELinux也处于启动状态,一般状态为enforing。致使很多服务端口默认是关闭的。所以好多服务初学者明明配置文件正确,等验证时有时连ping也ping不通。建议初学者在未学到SELlinux与iptables之前,把这两项都关掉。那么怎么关呢?1、关闭iptables#service iptables stop2、关闭SELinux#vi /etc/selinux/config将文件中的SELINUX="" 为 disabled ,然后重启。如果不想重启系统,使用命令setenforce 0注:setenforce 1 设置SELinux 成为enforcing模式setenforce 0 设置SELinux 成为permissive模式在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux#---------------------------------------------------------------查看selinux状态:/usr/bin/setstatus -v如下:SELinux status: enabledSELinuxfs mount: /selinuxCurrent mode: permissiveMode from config file: enforcingPolicy version: 21getenforce/setenforce查看和设置SELinux的当前工作模式
二、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效