摘自 How to Disable SELinux on CentOS 7 | Linuxize

1. 查看 SELinux 状态

> getenforce
Enabled
> sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31

2. 临时关闭 SELinux

setenforce 0 ## 设置为 Permissive 模式
setenforce 1 ## 设置为 Enforcing 模式

3. 永久关闭 SELinux

> vim /etc/selinux/config

# 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 - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

修改为SELINUX=disabled重启后生效

参考文章

  1. How to Disable SELinux on CentOS 7 | Linuxize
  2. CentOS 7.X 关闭 SELinux | 博客园
  3. CentOS 7 关闭 SELinux | CSDN