CentOS/Nginx WordPress Folder Permissions for Auto-Update and Plugin Install


Installation guides are not thoroughly clear on how to install WordPress on CentOS/Nginx, so that, a user can auto-update and install plugin from within WordPress without permission error hassles.

Debian based distribution guides recommend changing folder and file owner to www-data and adding HomeUser to www-data.

I have had a hard time finding who actually is the default user of nginx on CentOS. In the CentOS/LEMP guide we changed apache user to nginx in nginx.conf. That makes me think nginx should be the web server user on CentOS/Nginx.

Extrapolating the Debian guide here is what I think I should do on CentOS.

chown -R nginx:nginx wordpress/ usermod -aG nginx HomeUser

This should help me update WordPress using my HomeUser SSH login.

Next I am concerned about file permissions. Default folder permission of WordPress 755 and file permissions are 644. That will mean HomeUser which is added to group nginx will neither be able to write in folder group permission 5 equivalent to r-x or file group permission being 4 equivalent to r-- . These are WordPress recommended permission. WordPress recommends highly against 777 permissions.

What is the best possible thing I can do to maintain balance between usability and security?

Another question I have is who tends to be the owner of WordPress - web server user, mysql user, root user or home user?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

None of the above solutions worked for me using WP 4.8.2 on Centos 7.X and NGINX.

For anyone reading this, check your php-fpm configuration and make sure it’s the correct user running the module.

Running Centos 7 and nginx I had to change apache to nginx in /etc/php-fpm.d/www.conf and run sudo systemctl restart php-fpm.

I’ve been using a similar command along with 775 as the permissions. The idea is to use the group used by nginx and the user under which the profile is installed: <br> <br>chown -R wordpress:nginx /var/www/wordpress <br> <br>On my server I use: <br>chown -R sampleacct:nobody /home/sampleacct/public_html/ <br> <br>Then chmod 775 the directory and sub-directories.