April 26th, 2020 9:06 am

Correct file & directory permissions for WordPress

"If you get an FTP setup dialog when you try to install a plugin or theme, then most likely the file and directory permission for your WordPress installation is not set correctly."

In a hurry and don’t have time to read through the article? watch the video below

The WordPress documentation does not give you a specific answer and there’s a good reason for that. It’s because the permissions will vary depending on what hosting provider or Linux operating system you are using.

Follow the instructions below to set the the file permission for your WordPress installation.

Step 1: Find out which user is running the web server

Usually the user is apache on Fedora/Redhat/Centos distributions and www-data on Ubuntu/Debian distros. If you are not sure which user your web server is running as, run the following command

ps -ef | grep httpd | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'

If the above command return nothing, try either of these:

ps -ef | grep apache | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'
ps -ef | grep nginx | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'

This should return something like:

$ www-data

Step 2: Changing WordPress directory ownership

cd into your root WordPress directory (same directory as the wp-config.php file). Then set the file and directory ownership with the commands below:

sudo chown www-data:www-data -R *

Replace www-data with your web server user if necessary.

Step 3: Update WordPress directory permissions

The next step is to update the directory permissions to 755 as follow:

sudo find . -type d -exec chmod 755 {} \;

Step 4: Update the WordPress file permissions

And lastly let’s update the file permissions to 644

sudo find . -type f -exec chmod 644 {} \;

That’s it! you are done. You can now go and update WordPress, plugins and themes right from your admin dashboard.

Share it

James Reddy


James has been coding for the web since he got his first Pentium I PC back in 1996. With over 15 years professional web development experience and Linux administration, James decided to share his knowledge on WP Troll, a site dedicated to all things WordPress.


No comments

There are no comments for this post. Be the first to start the discussion!

Leave a comment

Your email address will NOT be published.
Please DO NOT use keywords in the name field.
Let's have a meaningful discussion.

Let us keep you updated. Get a weekly digest in your inbox.

Subscribe to the weekly articles digest.