A common issue in WordPress, especially when you’re the server admin, is incorrect file permissions or ownerships. The following is a workaround for almost every possible file or folder permissions issue you encounter when building a WordPress website, whether that’s the inability to update plugins, or access server resources, write to server, update files, create a new post, or one of the many permissions issues you can encounter with WordPress.

As stated on the WordPress documentation, permissions can be set to 644 for files and 755 for folders. To do so, these two commands when logged into your server shell or via your local environment’s terminal.

To make all folders have 755 permissions run the following command:

find /path/to/website -type d -exec chmod 755 {} \; 

(replace /path/to/website with your real path)

 

To make all files have 644 permissions run the following command:

find /path/to/website -type f -exec chmod 644 {} \; 

(replace /path/to/website with your real path)

 

Ownership controls which users and groups control the files. Usually, that’s www-data. So what you’ll need to do is run the following command:

sudo chown -R www-data:www-data /path/to/website 

(replace /path/to/website with your real path)

That’s it, you should be good to go! If you liked this tutorial, leave a comment below or share it on social.