WordPress Update Failed due to Permissions
Seeing a recent update that was released for WordPress (4.2.2), I decided it was a good idea to get caught up with the version as it patched the XSS vulnerability that was discovered a few weeks prior.
At a first glance, the assumption was that it would be as easy as pressing the Update button then I was greeted with this message: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.
More specifically the class-wp-filesystem-direct.php
and update-core.php
files under wp-admin/includes/
.
This can be easily resolved by resetting permissions to values that are preferred by WP (more on that here).
- Start by setting permissions of all FILES to
664
:sudo find /var/www/wordpress/ -type f -exec chmod 664 {} \;
- Then set the permissions of DIRECTORIES to
775
:sudo find /var/www/wordpress/ -type d -exec chmod 775 {} \;
- (OPTIONAL) Revert your site folder group to
www-data
or whatever you used for the initial setup by:sudo chgrp -R www-data /var/www/wordpress/