Easy WordPress file and database permissions and ownership

This post is short — no intro to UNIX file permissions or a plethora of commands, just how to easily setup WordPress file & database permissions!

File permissions and ownership

  1. Go to directory containing sites (assuming each site is a subfolder):
    cd /var/www/
  2. Set the web service account as the owner (assuming Debian-y):
    sudo chown -R www-data:www-data
  3. Go into the site directory:
    cd  wordpress
  4. Set the correct permissions:
    sudo find . -type f -exec chmod 664 {} \; && sudo find . -type d -exec chmod 775 {} \; && sudo chmod 660 wp-config.php

Database privileges

The database user requires the following permissions on the WordPress database:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE
  • ALTER

If you’re on shared hosting you may not be able to change this, in which case skip this section.

That’s it!

Leave a Reply

Your email address will not be published.