WordPress Update Installation Failed How To Fix SELinux

I recently came across a problem when trying to update WordPress that was running on Centos 7. Whenever I tried to run the WordPress update from the admin area I got the following error:

Unpacking the update…

The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php

Installation Failed

From the error I initially thought this was a simple file permissions issue however after checking the the permissions on the WordPress installation everything appeared to be OK.

After some reading up online there were a number of people talking about SELinux. SELinux stands for Security Enhanced Linux and its a security module that supports access control policies and is built into a number of Linux distributions including Centos 7.

In my case this module was causing the updates to fail with the above error.

So before you run your updates you need to SSH to your server and run the following command to disable SELinux:

Sudo setenforce 0

Then run your WordPress updates. Once they are complete, enable SELinux again by running the following command:

Sudo setenforce 1

Hope you find this useful.