1

I'm running WordPress version 4.7.1 on a few machines (Ubuntu 14.04.5 + Nginx) and want to upgrade to 4.7.3. However when I try to run the updated through WP-Admin it gives:

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

So I thought was some permissions issue, I updated using the following:

find /var/www/site -type f -exec chmod 664 {} \;
find /var/www/site -type d -exec chmod 775 {} \;
chmod 600 /var/www/site/wp-config.php 

But that too did not correct the issue - still gives same error.

If I run chown -R www-data:www-data . it seems to work fine but worried about security...any thoughts?

1

Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files should never be owned by the webserver process itself (sometimes this is www, or apache, or nobody user).

Reference - Wordpress Codex

Here's a script I run on my webroot to set permissions. This is on my AWS EC instance. I have a little more on permissions here.

chown -R myusername:www-data /var/www/*
# This part runs for each wordpress install individually
find /var/www/sp -type d -exec chmod 755 {} \;
find /var/www/wp -type f -exec chmod 644 {} \;
find /var/www/wp/wp-content/uploads -type f -exec chmod 664 {} \;
find /var/www/wp/wp-content/plugins -type f -exec chmod 664 {} \;
find /var/www/wp/wp-content/themes -type f -exec chmod 644 {} \;
chmod 440 /var/www/wp/wp-config.php
chmod -R g+s /var/www/wp/

My web server user, nginx, is a member of the www-data group

  • Thanks for quick reply. Sorry I didn't note that in the original post - this is not shared hosting. These are EC2 instances on AWS. But we did not enable FTP on the server for security purposes...is it required that we enable FTP? Or is it fine that we use the www-data:www-data? – Aaron Mar 31 '17 at 8:36
  • Answer above expanded. Doesn't matter where you're hosted, same guidelines apply. I run Wordpress on EC2. sftp is part of the included ssh daemon. – Tim Mar 31 '17 at 18:31
  • Thanks for the script. Im assuming the first line is meant to be run from the document root location of WP. However, now when I try to upgrade (either plugin or WP) it says "Could not create directory." Here is screenshot of plugins directory so you can see the permissions. dropbox.com/s/pbmv5vdlhw6xi5g/wp-plugins-folder.png?dl=0 – Aaron Apr 1 '17 at 10:15
  • This of course is a permissions problem. I can't fully answer it is I don't have all the information. Work out what folder is trying to be made, by which user, then work out what permissions are required. For example I have php running as the user who owns those files, which is probably not the way it's meant to be done, but I did it a long time ago and haven't needed to change. Read the Wordpress Codex page I linked to fully, I haven't done that recently but it probably has the answer. Other pages say make www-data the owner of the webroot, I'm not really an expert, read around. – Tim Apr 1 '17 at 19:53
  • So I was able to determine the user for the nginx daemon which is in fact www-data. Makes sense that when I chown the document root for this user that it works perfect. My only concern was the security part... :) – Aaron Apr 2 '17 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.