How to disable SELinux in CentOS 7

Reading Time: < 1 minute

If you have challenges in letting WordPress creates its own .htaccess in your CentOS 7 Virtual Machine, better disable SELinux instead.

What is SELinux?

enforces mandatory access control policies that confine user programs and system servers, access to files and network resources.

Limiting privilege to the minimum required to work reduces or eliminates the ability of these programs and daemons to cause harm if faulty or compromised (via buffer overflows or misconfigurations, for example).

To do so, check current status of SELinux by running the command below:

sestatus

You should have the same output below:

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

As you can see from the output above that SELinux is enabled and set to enforcing mode.

Let us disable SELinux by updating SELINUX mod to disabled, run the command below:

nano /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 these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted

Save the config file and reboot your CentOS.

reboot

Verify your changes with the sestatus command.

sestatus

You should have the same output below:

SELinux status:                 disabled

From here, you should be all set. Great Job.

Was this post helpful?

Leave a Reply