Help: Wordpress do not have write permissions.

I have CentOS 6 installed on my droplet and I have created some virtual hosts to use some domains. Now, I have installed Wordpress on one of vhost and the problem is, Wordpress do not have write permissions. I can not install themes, plugins or upload images from Wordpress admin.

The folder ownership is for a user that I created apart from root.

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.

sudo chown apache:apache -R *
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

You need to operate your WP site in two modes: <br> <br>- lockdown mode (the Apache service account owns none of the files) <br>- admin mode (the Apache service account owns all of the files) <br> <br>You can write a simple script to handle this so that you will know 100% the state of file ownership and permissions. The only time you would run in admin mode is when you are installing a new plugin/theme, or performing a manual Wordpress update. <br> <br>In a nutshell, your lockdown mode should look something like this (the wpadmin user/group is a normal account (something other than your httpd service account): <br> <br># The web server account should not have ownership of any files <br>chown -R wpadmin:wpadmin /path/to/docroot/ <br> <br># Setting full control for owner and group. Setting read-only for everyone else. <br>chmod -R ug=rwX,o=rX /path/to/docroot <br> <br># Allow the web server to write files to the uploads dir <br>chmod -R a=rwX /path/to/docroot/wp-content/uploads <br> <br> <br>Your admin mode is simply changing the ownership of all files to the web server service account: <br> <br># Apache should only own the files if needed (for updates or installs) <br># Allow Apache to own files for updates and installs <br> <br>chown -R apache /path/to/docroot <br> <br> <br> <br>If you have developers that need to run this command, you can do so with sudo. You can further write a script that allows the developers to specify a particular top-level directory under your Apache document root (assuming you have multiple vhosts on the server). <br> <br> <br>Lastly, If you want to control the group ownership of files that are uploaded via Wordpress (and you probably will), it’s best to configure a custom php upload directory (in the php.ini) and then use the setgid permission on the folder so that new files will pickup your group of choice. I think this is a better and safer solution over trying to configure suexec. <br> <br> <br>

I would recommend Pablo of vDevices’ solution. There should be no need to add your user account to the apache group.