| Linux下禁用与启用SeLinux 
 
 
	在php调用system()函数时或者c、c++等一些语言中要运行一些系统命令来执行某种操作,就要修改SELinux中的配置。 
	一些Linux默认都是启用SeLinux的,在安装操作系统的时候我们可以选择开启或者关闭SeLinux,但是在安装完系统之后又如何开启与关闭呢?在/etc/sysconf下有一个SeLinux文件,使用vi打开,更改其中的SELINUX项的值就可以了。
 SELINUX=disable  禁用SeLinux
 SELINUX=enforcing  使用SeLinux
 
	关闭SELinux 
	1.无需重启而暂时关闭SELinux 
	以root用户运行以下命令# setenforce 0
 
	这条命令的作用是把SELinux暂时设定成Permissive模式(关于Permissive Mode在以下会有介绍) 
	如果要恢复运行SELinux则可以运行# setenforce 1
 
	这条命令会把SELinux设定成Enforcing模式 
	2.把SELinux永久设定为Permissive模式 
	这里需要讲一下Permissive和Enforcing模式的区别。 SELinux有三种模式:Enforcing, Permissive and Disable. 
	Enforcing模式就是应用SELinux所设定的Policy, 所有违反Policy的规则(Rules)都会被SELinux拒绝Permissive和Enforcing的区别就在于它还是会遵循SELinux的Policy,但是对于违反规则的操作只会予以记录而并不会拒绝操作
 
	Disable 完全禁用SELinux 
	如果要永久设定为Permissive模式,就要修改SELinux的配置文件 /etc/sysconfig/selinux (在RHEL5下这是一个symbolic link to /etc/selinux/conf)# This file controls the state of SELinux on the system.
 # SELINUX= can take one of these three values:
 # enforcing - SELinux security policy is enforced.
 # permissive - SELinux prints warnings instead of enforcing.
 # disabled - SELinux is fully disabled.
 SELINUX=enforcing
 # SELINUXTYPE= type of policy in use. Possible values are:
 # targeted - Only targeted network daemons are protected.
 # strict - Full SELinux protection.
 SELINUXTYPE=targeted
 
	修改SELINUX=permissive,重启生效。 
	 (责任编辑:IT) |