Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Fix wordpress file permissions
# This script configures WordPress file permissions based on recommendations
# from
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
WS_GROUP=www-data # <-- webserver group
# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 660 ${WP_ROOT}/wp-config.php
# allow wordpress to manage wp-content
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \;
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \;
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \;

timbru31 commented Jun 8, 2014

thanks! :)

tcope25 commented Jul 23, 2014

this worked perfect for me. Thanks!

This saved me! thank you! my site was totally offline for some reason and this solved it. double thumbs up


ghost commented Jun 3, 2015

So, I used this because my wp-content/uploads was giving me permission errors (on a new install).
It works now, however since the data is now "owned" by www-data, i can no longer edit files via ftp.
I tried adding the user that I use to ftp to the www-data group, but that doesn't seem to work. Any thoughts?


ghost commented Jun 3, 2015

Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files should never be owned by the webserver process itself (sometimes this is www, or apache, or nobody user).

smuralii commented Nov 3, 2015

This works link a charm. Thank for the resource.

alagu commented Apr 10, 2016

Worked like magic.

malhal commented May 14, 2016

Fixed all my problems thanks

I'm sorry, but i dont know how this works, someone can explain it pls? I've got a problem w/ wordpress permissions and this seems to be a solution.


h3nr1ke commented Aug 22, 2016

thanks man..

hi bro, why show me this:

felipe@felipeurrego:/var/www/html$ sudo ./
chgrp: cannot access ‘/wp-config.php’: No such file or directory
chmod: cannot access ‘/wp-config.php’: No such file or directory
find: `/wp-content': No such file or directory
find: `/wp-content': No such file or directory
find: `/wp-content': No such file or directory

Also getting the

find: `/wp-content': No such file or directory
find: `/wp-content': No such file or directory
find: `/wp-content': No such file or directory

malhal commented Sep 28, 2016

You need to supply the folder your wordpress is in, e.g. ./ wordpress

NatiNog commented Oct 18, 2016

Thank you!!!
I was wondering if you could tell me why I'm getting this error when trying to update the core:
"The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php"

kikoking commented Feb 5, 2017

NaitNog - "You need to supply the folder your wordpress is in, e.g. ./ wordpress". I get a permission denied when trying to run this. Also just wondering, is it necessary to set this? Is this something that should be set when installing wordpress out of the box every time? I'm just wondering because I had a few permissions issues after installing wordpress with wget in terminal, but it was resolved by running chown -R ftpusername:ftpusername *

find: `/wp-content': No such file or directory

That is happening because that is not the path to your directory. You may need to add /var/www/vhosts/

which would be the full folder path. This example path might not be the same as yours, it is just an example. Basically you need a more precise path.

#create ("sudo nano" and put the content in it)
chmod +x (give execute permissions)
./ . (execute)

richb-hanover commented Mar 28, 2017

@Adirael Thanks for this script - it worked fine! Many of the questions above would go away if you could add this explanation after line 6 of the original script:

# Source for this script:
# To use this script, supply the full path to your wordpress directory
# That directory is often in /var/www, and the wordpress directory is frequently named 'wordpress'
# The example below operates on /var/www/wordpress directory
# sudo sh ./ /var/www/wordpress

boaglio commented May 6, 2017


Thank you so much! Can't believe I just found this now.

daudi250 commented Jun 13, 2017

the struggle for this one is real. tried so many time and failed. finally worked with the help @richb-hanover comment.

So i will explain the thing further.

  1. you need to make a .sh file.
  2. create a new file under the name of fix-wordpress-permissions and use .sh as its extension
  3. add the above content.

now comes the tricky part.

you need to upload the file, where your website or wordpress is being hosted i.e. the directory/path/wordpress for eg.


I am using Ubuntu 16 on amazon ec2 and i have installed VestaCP. Therefore the path of my directory is the one mentioned. You path can be

/Var/www/wesite/yourwebiste or something.

It all depends where the website is installed.

How i got here?

I used SSH to login and navigated here using CD command.

cd /home/admin/web/mywebsite/public_html.

  1. You need to upload the .sh file over here using filezilla or scp or cybercuk or whatever software you want to use..

  2. now execute the command as mentioned by @pankaj

chmod +x (gives execute permissions)

You need to be in the directory of your wordpress (do remember this prior executing the command)

sudo sh ./ /home/admin/web/yourwebsite-goes-here/public_html (use this command to execute).

Please do note that this is my directory and your directory can be different. you need to be in the directory of your wordpress installation to execute the command.

When you press enter it will work. Wait for sometime.
screen shot 2017-06-13 at 11 19 08 pm

Works great! Thank you :D

neel92 commented Sep 27, 2017

It's work. Thanks !!

i love this and use it frequently, you rock

Very helpful! Thanks

Thanks, it works perfect, but something like this, at start, would be fine to prevent no parameter error:
# alert if no parameters if [[ $# -eq 0 ]] ; then echo 'Error. You need to spacify folder, example: ./ public_html' exit 0 fi

Thanks a lot!

nice work

Thank you! I only regret not finding this earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment