Upgrade WordPress Failed

Issue

Got following two permission issues when I was trying to upgrade WordPress to latest version.

My WordPress environment:

  • WordPress 5.7
  • Centos 8.2
  • Nginx 1.14.1
  • PHP 7.2.24 (cli)
  • PHP-FPM 7.2.24 (fpm-fcgi)

Issue #1

Some files are not writable by WordPress:
xmlrpc.php
wp-blog-header.php
readme.html
wp-signup.php
index.php
wp-cron.php
wp-config-sample.php
wp-login.php
wp-settings.php
license.txt
wp-mail.php
....

Issue #2

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.

Solution

I have google lots of articles and most of them are to check/update the permission of Folders and Files of WordPress. And the recommendation permissions settings are:

Folders – 755
Files – 644
wp-config.php – 600
.htaccess – 644, or 600

I have done this by following commands:

Change permissions for WordPress Folders 755:

$ sudo find /your_wordpress_folder/ -type d -exec chmod 755 {} \;

Change permissions for WordPress Files 644:

$ sudo find /your_wordpress_folder/ -type f -exec chmod 644 {} \;

Change permissions for wp-config.php

$ sudo chmod 600 wp-config.php

Since I’m using nginx + php-fpm, so I have also set the ownership as following command:

$ sudo chown -R nginx:nginx /your_wordpress_folder/

At last I restarted service with following cmmands:

$ sudo systemctl restart nginx
$ sudo systemctl restart php-fpm

With above steps I have fixed issue #1, but got issue #2 errors.

It did take me lots of time to search and try to fix issue #2, but at last I’m lucky to find a solution which resolved issue #2.

$ sudo setenforce 0

Note that you should set it back to restrict mode after upgrade your WordPress site:

$ sudo setenforce 1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.