Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress file permissions on CentOS7 requiring sudo

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?

like image 203
fortuneRice Avatar asked Sep 21 '16 03:09

fortuneRice


People also ask

What permissions should WordPress files have?

Generally, WordPress directory and folder permissions should be set to 755, and most file permissions need to be set to 644. These are also the file permissions that WordPress recommends you set for your site. These are also the permissions needed for WordPress auto update to function correctly.

How do I fix file and folder permissions in WordPress?

Fix File and Folder Permissions in WordPress Using FTPOnce connected go to the root folder of your WordPress site. After that select all folders in root directory and then right click to select 'File Permissions'. This will bring up the file permissions dialog box. Now you need to enter 755 in the numeric value field.

How do I change file system permissions in WordPress?

Select File Manager. Right-click on your WordPress folder and select Change Permissions. Enter 755 in the Permission fields. Click Change Permissions to continue.

How do I give permission to run Centos?

Type the "CHMOD" command to make the change you need to the file's permission. For example, if you want to make a shell script called "listallfiles" executable, type "chmod +x listallfiles" at the command prompt.


1 Answers

Look at:What does mode_t 0644 mean?

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

CRUD is a write command, so you're not allowed to do that. Either you change to 664 or keep using sudo. Basically any writing procedure on the file system would not be allowed without sudo since your user is not the owner (event though he is in the group).

like image 62
kabanus Avatar answered Sep 16 '22 12:09

kabanus