How do you setup proper group and user permissions on Centos for multiple WordPress installs?

October 24, 2016 144 views
Apache WordPress Security CentOS

I have a CentOS box running with multiple WordPress installs. Here are the steps I followed to setup each directory and install.

  1. Created folder within /var/www/{websiteurl}
  2. Created config inside httpd for multiple domains
  3. Created a new user for each website and added them to a group called clients
  4. chown newuser:newuser /var/www/[userwebsite folder]
  5. Confirmed all permissions were set to meet WordPress hardening requirements. https://codex.wordpress.org/Hardening_WordPress 644 for files and 755 for directories

Now, however since making these changes from apache:apache owning all of the file my users can not upload to /wp-content/uploads. What changes do I need to make to make this happen? I would like to ensure the most amount of security, but also give my users the ability to upload files and install plugins. To patch the issue for now I chown apache:apache /var/www/[userwebsite]/public_html/wp-content/uploads/

Thanks for any suggestions or help you can provide.

1 Answer

Hi!

One option to solve this issue would be chowning the uploads directories' to apache:apache and adding your users to the apache group. This will allow Apache access only to the directories that it should write to while still allowing your users access to everything. However, this will require you to chmod the directories to 775 and the files to 664 in order to allow the members of the group that owns them (apache, as in the other users) to write to them.

  • Would I have to chmod all directories to 775 or only wp-content? I assume all files and directories (besides wp-content) could be user:user and the permissions could stay the same, correct?

    • Only the directories that you will chown to apache:apache. If they were to stay at 755—which is equivalent to user:read,write,execute; group:read,execute; other:read,execute—your users would not be able to write to them as they are part of the group that owns the directories, which does not have write permissions. So, you will have to give the group write permissions.

      Take a look at the following tutorial for a more in-depth explanation about Linux ownership and permissions:

      Linux is a multi-user OS that is based on the Unix concepts of file ownership and permissions to provide security, at the file system level. If you are planning improving your Linux skills, it is essential that have a decent understanding of how ownership and permissions...
Have another answer? Share your knowledge.