7

I have a local wordpress installation and got everything working, until I tried to install a new plugin. Trying to activate the plugin, wordpress asked me for FTP connection information, which I understood to be a failure of write-access to the plugins directory. Apache runs as www-data, so I ran sudo chown -R www-data: /var/www/wordpress to make the wordpress directory writable for Apache. But now, I cannot edit the files as user anymore. Changing file permissions back to chown -R user: /var/www/wordpress/wp-content/themes, the wordpress dashboard complains again, that it doesn't have sufficient access.

I tried various "solutions" online, but none have worked so far. Do I really need to install something like proftp and create an FTP user & password for my local server? Or can I circumvent the problem with some nifty file permission settings, which allow both me and Apache to access/write the files?

1

1 Answer 1

12

It sounds like you've already got it figured out, but I'll let you know how I did it. This set up lets me and apache write to the wordpress directory, and the plugin/theme/upgrade works fine from within Wordpress.

First, I made my user part of the www-data group: sudo usermod -G www-data -a <user>.

Next, I made the entire wordpress directory owned by www-data:www-data: sudo chown -R www-data:www-data wordpress. I also made all the files readable and writable by user and group: find wordpress -type f -exec chmod 664 {} +, find wordpress -type d -exec chmod 775 {} +.

Finally, I set the guid bit so that new files would also be group-owned by www-data: chmod -R g+s wordpress.

Now, this isn't the most secure setup. Any vulnerabilities in Wordpress could be used to write to files within your wordpress installation. But I, personally, have never had any problems. And when I tried to make it less restrictive, updates and theme/plugin installation from within Wordpress Admin usually broke. I never quite found the right sweet spot between security and usability.

10
  • that's a fairly secure way to do it, actually, and is far better than a lot of the advice out there involving chown/chmod. Commented Dec 12, 2012 at 17:17
  • Yeah, it's better than doing chmod -R 777 wordpress which I've actually seen suggested, but I've seen better ways suggested, like only giving write permissions to wp-content. I was just never able to get the extra secure setups to work well for me. But yeah, I think I've struck a pretty decent balance.
    – Dan Jones
    Commented Dec 12, 2012 at 17:21
  • Thanks, this worked much better than what I had found earlier.
    – Earthliŋ
    Commented Jan 3, 2013 at 16:02
  • 1
    Glad I could help.
    – Dan Jones
    Commented Jan 3, 2013 at 19:49
  • I needed more permissions to create, update and delete folders and the files below on Ubuntu 13.10: sudo find wordpress -type d -exec chmod 775 {} +
    – malisokan
    Commented Feb 9, 2014 at 15:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .