WordPress file permissions for editing on local Ubuntu development machine

I’ve seen a couple of solutions on this site that solved some permission problems, however, they seem that they create others, at least for me. My setup is a local wordpress installation on Ubuntu 14.04.

For example: when I want to install a plugin from within my wordpress admin area, I used to get asked to enter my FTP details. Surfing for an answer, I found that changing your user:group to www-data:www-data would solve it, and indeed it did.

However, upon making that change, my files stopped being writable from any editor. I tried adding my current user name nasser to the www-data group (I did this with sudo adduser nasser www-data) and even changed all of my file permissions to 775, but to no avail.

So now, I’m switching back and forth between owners/groups if I want to add a plugin or theme while editing. I could settle for simply downloading a plugin/theme and unzipping it manually into wp-content/plugins or /themes Even unzipping a theme/plugin and manually copying it to the appropriate location would require a permission change.

Any help would be much appreciated. If I missed any details, or was unclear, please let me know.

1 Answer
1

I’m too working on Ubuntu, personally I’m setting things up like this:

sudo chown -R nasser /path/to/your/wordpress/root/
sudo chgrp -R www-data /path/to/your/wordpress/root/
sudo chmod -R 775 /path/to/your/wordpress/root/

I only do this on my local development machine for convenience and a smoother work-flow. One more thing to note, I’ve moved the www directory into the home directory, symlinking from /var/www/ to /home/user/www/, which is convenient, but shouldn’t be necessary.

Do not forget to revert this back before deploying, for this do at the very least this:

sudo chown -R www-data /path/to/your/wordpress/root/
sudo chgrp -R www-data /path/to/your/wordpress/root/
// the last two lines can be combined like:
// sudo chown -R www-data:www-data /path/to/your/wordpress/root/
sudo find /path/to/your/wordpress/root/ -type f -print0 | xargs -0 sudo chmod 644
// the last line could also be done like this:
// sudo find /path/to/your/wordpress/root/ -type f -exec chmod {} 644 \;
sudo find /path/to/your/wordpress/root/ -type d -print0 | xargs -0 sudo chmod 755
// the last line could also be done like this:
// sudo find /path/to/your/wordpress/root/ -type d -exec chmod {} 755 \;
sudo chmod 600 /path/to/your/wordpress/root/wp-config.php

You might of course have other wishes for your file permissions, more about that in the codex articles Changing File Permissions and Hardening WordPress – File Permissions.

Leave a Comment