File Ownership and Permissions

In order for some of WordPress’ features to function, it will need write access to your site’s files and folders. This is true of the following features:

  • Media Library uploads
  • Adding/updating plugins and themes
  • Updating WordPress core

If you manage WordPress core, plugins, and/or themes via git, Composer or some other deployment process, WordPress will not need write access for these operations.

SpinupWP will automatically handle file permissions for any tasks it carries out on your server. However, if you manually run commands on the server you will be responsible for setting the correct file permissions.

Ownership

All files and folders within /sites/{domain}/ should be owned by the site user. This will ensure WordPress is able to write to those folders. The group can be anything you chose.

When running commands directly on the server, generally any new file or folder will be owned by the user executing the command. Therefore, when making changes to a site we recommend that you SSH or SFTP using the site user. This will ensure file permissions are correct. However, if you use a sudo user it will often be necessary to change ownership, like so:

sudo wp plugin install woocommerce --allow-root
sudo chown -R {site_user}:{site_user} ./wp-content/plugins/woocommerce

However, a much simpler approach is to run the CLI command as the site user:

sudo -u {site_user} wp plugin install woocommerce

Read, Write, Execute

If all files and folders are owned by the site user the following permissions should be used:

  • Files should be 644
  • Folders should be 755

If you also want to grant write access to the group:

  • Files should be 664
  • Folders should be 775

Be careful when using chmod recursively, because this can lead to undesirable results. Instead, we recommend that you explicitly define the permissions for files and folders, like so:

  • For files: sudo find . -type f -exec chmod 644 {} +
  • For folders: sudo find . -type d -exec chmod 755 {} +

Ready to give SpinupWP a try?

Not sure if SpinupWP is the right fit for you? Send us an email at sudo@spinupwp.com and we’ll give you our no-BS opinion.