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?

  • Why have you made the files owned by apache? – Michael Hampton Sep 18 '16 at 5:40
  • @MichaelHampton according to this guide, 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 5: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. – Michael Hampton Sep 18 '16 at 5: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 7: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 7:14

Your Answer

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

Browse other questions tagged or ask your own question.