0

I'm running WordPress on my VPS with CentOS 7 LAMP stack.I've followed this guide to set permissions, i.e. I've run

sudo chown apache:apache -R * to ensure that my wordpress directory is owned by apache:apache.

I've also set WordPress directory and file permissions with these commands:

find . -type d -exec chmod 755 {} \;

find . -type f -exec chmod 644 {} \;

(I had to prefix the above commands with sudo)

Normally I manage the server by logging in through SSH using myuser, where myuser belongs to the apache group and the wheel group.

I have 3 problems:

  1. Any file CRUD command in the WordPress directory still requires me to prefix the command with sudo, or else I get a permission error. Since myuser belongs to apache and apache owns the directory, I'm confused as to why I still need to prefix the commands with sudo.
  2. Similar to problem 1, any git command such as a git pull requires me to prefix the command with sudo or else I get a permission error.
  3. When I try to automatically update theme files from my WordPress dashboard web interface, I get permission errors. Interestingly, I'm able to install/update plugins via the WordPress dashboard without any permissions errors.

Any ideas on what I'm missing?

fortuneRice
  • 65
  • 1
  • 7
  • Why have you made the files owned by apache? – Michael Hampton Sep 18 '16 at 05:40
  • @MichaelHampton according to [this guide](http://www.stevejenkins.com/blog/2015/09/correct-permissions-for-wordpress/), _WordPress works best if its files are “owned” by the same user that runs the web server. On Fedora/RedHat/CentOS platforms, the user’s simply apache._ – fortuneRice Sep 18 '16 at 05:45
  • That guide is crap. (Like so much of the Internet.) If you really want WordPress to be able to overwrite itself, my suggestion is [to use ACLs](http://serverfault.com/a/484819/126632). – Michael Hampton Sep 18 '16 at 05:53
  • @MichaelHampton thanks for the pointer I'll look into it. I'm still confused about Q1 though (why I still need to prefix commands with sudo). Any thoughts? – fortuneRice Sep 18 '16 at 07:06
  • Because neither your user nor group is `apache`. You could have switched group to apache instead of switching user to root. – Michael Hampton Sep 18 '16 at 07:14
  • @MichaelHampton sorry I don't fully understand what's meant by "neither your user nor group is `apache`". I specifically set `myuser` to belong to the `apache` group; I thought this would give it the appropriate permissions? I'm new to linux permissions in general, thanks for the patience. – fortuneRice Sep 18 '16 at 14:52

0 Answers0