Fix WordPress automated update has failed to complete
I decided to host one of my WordPress sites on AWS and created an Ubuntu 16 instance. However, when I wanted to update WortPress I got an error message: “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”
Here is how you can fix this problem:
Let’s back up for a second, if WordPress is requiring you to enter FTP credentials when you attempt to upgrade, you need to enable direct update first. Open your wp-config.php and add the following code to the end of the file.
1
|
define( 'FS_METHOD' , 'direct' ); |
This enables direct update mode and the system would stop asking you about the FTP credentials when you attempt to upgrade.
Now, we need to fix the permissions of the files and folders. First we need to figure out the user Apache2 is running under. Use the following command to identify the user:
1
|
ps -eF | grep -i apache2 |
The result is something like this:
1
2
3
4
5
6
7
8
9
10
11
|
root 12351 1 0 83867 29544 0 Nov20 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12354 12351 0 103512 42444 0 Nov20 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12358 12351 0 103053 43160 0 Nov20 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12395 12351 0 104122 47168 0 Nov20 ? 00:00:01 /usr/sbin/apache2 -k start www-data 12397 12351 0 104618 48016 0 Nov20 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12439 12351 0 104477 47272 0 00:01 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12440 12351 0 104199 51356 0 00:01 ? 00:00:01 /usr/sbin/apache2 -k start www-data 12441 12351 0 84217 31904 0 00:01 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12442 12351 0 104650 50044 0 00:01 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12445 12351 0 102976 46924 0 00:01 ? 00:00:00 /usr/sbin/apache2 -k start www-data 12448 12351 0 102935 45064 0 00:01 ? 00:00:00 /usr/sbin/apache2 -k start |
In my case it was the www-data. Now we’ll fix the group permissions:
1
|
sudo chgrp -R www-data / var /www/sitename |
lets fix the directory and file permissions:
1
|
sudo find / var /www/sitename/ -type d - exec chmod 775 {} \; |
1
|
sudo find / var /www/sitename/ -type f - exec chmod 664 {} \; |
After fixing the permissions and user permissions, WordPress should be able to update itself without requiring FTP credentials.