WordPress file permissions for CentOS7 requiring sudo

I am running WordPress on my VPS using the CentOS 7 LAMP stack. I followed this guide to set permissions, i.e. I ran

sudo chown apache:apache -R * so that my wordpress directory belongs to apache:apache .

I also set the permissions for WordPress files with these commands:

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

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

(I had to prefix the above commands with sudo )

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

I have 3 problems:

  • Any CRUD command in the WordPress directory still requires me to prefix the sudo , otherwise I get a permission error. Since myuser owned by apache and apache owns the directory, I am confused about why I still need a command prefix using sudo .
  • As with issue 1, any git command, such as git pull , requires me to prefix the sudo , otherwise I get a permission error.
  • When I try to automatically update theme files from my WordPress toolbar web interface, I get permission errors. Interestingly, I can install / update plugins using the WordPress dashboard without any permissions errors.

Any ideas on what I am missing?

+5
source share
3 answers

Take a look: What does mode_t 0644 mean?

 644 means: * (owning) User: read & write * Group: read * Other: read 

CRUD is a write command, so you are not allowed to do this. Either you switch to 664 , or you continue to use sudo. In principle, any write procedure in the file system will not be allowed without sudo, since your user is not the owner (event, although he is in the group).

+6
source

@fortuneRice, CentOS7 is selinux enabled by default, which often causes many hard-to-access file resolution errors.

I would suggest the following:

  • Edit / etc / sysconfig / selinux
  • Change SELINUX = enable (or any of which SELINUX is currently set in the file) to SELINUX = disabled
  • Reboot the server (not just the apache web server, but the whole machine)

Disabling SELINUX is not a good idea at all, so if this procedure works, you must enable SELINUX again and correct its configuration.

Configuring SELINUX can be a difficult task, so I suggest you read on Google how to do it :)

+3
source
 chown -R -f user:apache /path of the directory 
+1
source

All Articles