Nginx – Server permissions issue with latest WordPress upgrade

file-permissionsnginxubuntu-14.04Wordpress

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?

Best Answer

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

Related Topic