Reputation: 1048
I keep getting this error message when I try to automatically update WordPress to 4.7.2 through the admin:
Update WordPress Downloading update from https://downloads.wordpress.org/release/wordpress-4.7.2-new-bundled.zip…
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
I tried running the following commands from this article on my server and I am still getting an error message:
sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
sudo chmod 660 wp-config.php
What am I doing wrong? Shouldn't the automatic update work with the correct file/folder permissions?
Upvotes: 14
Views: 24337
Reputation: 933
A note for any future readers. Even if your file/directory ownership and permissions are correct, this problem can still be caused by SELinux denying write access to the files in your WordPress directory.
To debug:
getenforce
Will tell you whether SELinux is running.
If it is, check the SELinux context on your WordPress files with
ls -Z /path/to/wordpress
If your files have a "type" context (the third segment of the list) of
httpd_sys_content_t
this means that SELinux considers them to be read-only config files and will not allow your web server to write to them.
You can update the context with
chcon -R -t httpd_sys_rw_content_t /path/to/wordpress
this will set them to a context which allows your web server to write to them. Note, this then delegates responsibility to the file system permissions to allow or not any operations. So, for example, setting the context as above will not allow nginx to write to files owned by root. It just allows the possibility of writing to them, if the file permissions allow it.
Upvotes: 0
Reputation: 579
If your Wordpress is installed with Bitnami, use these commands. (bitnami:daemon)
TARGET is the WordPress application folder:
sudo chown -R bitnami:daemon TARGET
sudo find TARGET -type d -exec chmod 775 {} \;
sudo find TARGET -type f -exec chmod 664 {} \;
sudo chmod 640 TARGET/wp-config.php
ref: https://docs.bitnami.com/bch/apps/wordpress-pro/administration/understand-file-permissions/
Upvotes: 1
Reputation: 612
Ran these commands, and it’s now working just fine (both dashboard and ftp).
sudo usermod -aG www-data $USER
sudo chown -R www-data:www-data /var/www
sudo chmod -R 774 /var/www
Upvotes: 1
Reputation: 4168
For me, the command below worked. In the example below, replace "www-data" with the name of user under which the web server service runs. Also replace "/path/to/site" with the actual path to the root of your WP site.
chown -R www-data:www-data /path/to/site
IMPORTANT Be sure to revert this afterwards by granting ownership back to a regular user (not the web service user) otherwise it will not be secure at all. Also, leave the web service user as owner of the wp-content/uploads folder so that users can upload media.
chown -R user:group /path/to/site
chown -R www-data:www-data /path/to/site/wp-content/uploads
Upvotes: 9
Reputation: 1962
Have you tried manually uploading the updated WordPress files, via a programme such as FTP (Filezilla)? Do you still get the same problem?
Update:
Run the following
Reset the permissions of all files to 664:
find /path/to/site/ -type f -exec chmod 664 {} \;
Reset permissions of directories to 775:
find /path/to/site/ -type d -exec chmod 775 {} \;
Reset the group to the wordpress group (or whatever group makes sense for you)
chgrp -R wordpress /path/to/site/
Upvotes: 13
Reputation: 9121
For me all suggested solutions did not work because I am using a Plesk cpanel, what worked for me is updating WordPress manually following steps mentioned here:
1- First create a full backup of your website. This is very important in case you make a mistake.
2- Download the newest WordPress ZIP file from wordpress.org.
3- Unzip the file into a directory on your local machine or in a separate directory on your website.
4- Deactivate all of the plugins on your WordPress site.
5- Go to your website root directory and delete your ‘wp-includes’ and ‘wp-admin’ directories. You can do this via sFTP or via SSH.
6- Upload (or copy over) the new wp-includes and wp-admin directories from the new version of WordPress you unzipped to your website root directory to replace the directories you just deleted.
7- Don’t delete your wp-content directory or any of the files in that directory. Copy over the files from the wp-content directory in the new version of WordPress to your existing wp-content directory. You will overwrite any existing files with the same name. All of your other files in wp-content will remain in place.
8- Copy all files from the root (‘/’) directory of the new version of WordPress that you unzipped into your website root directory (or the root directory of your WordPress installation). You will overwrite any existing files and new files will also be copied across. Your wp-config.php file will not be affected because WordPress is never distributed with a wp-config.php file.
9- Examine the wp-config-sample.php which is distributed with WordPress to see if any new settings have been added that you may want to use or modify.
10- If you are upgrading manually after a failed auto-update, remove the .maintenance file from your WordPress root directory. This will remove the ‘failed update’ message from your site.
11- Visit your main WordPress admin page at /wp-admin/ where you may be asked to sign-in again. You may also have to upgrade your database and will be prompted if this is needed. If you can’t sign-in, try clearing your cookies.
12- Re-enable your plugins which you disabled earlier.
13- Clear your browser cache to ensure you can see all changes. If you are using a front-end cache like ‘varnish’ you should also clear that to ensure that your customers can see the newest changes on your site.
14- Your upgrade is now complete and you should be running the newest version of WordPress.
Upvotes: 0
Reputation: 600
I had similar issues with updating on my local. I ended up using wp-cli: http://wp-cli.org/
If you have ssh access it is worth checking out. I ran a sudo wp core update --allow-root
(not recommended for live site) and its updated with no permission error.
Upvotes: 1