I've read articles about protecting wp-config.php using .htaccess as well as setting the correct file permissions but I want it all in one place. What should my .htaccess file look like and what folders is it safe to have 777 vs 755 permissions?

4 Answers 4


Hardening WordPress on the WordPress Codex is a very good article on how to secure your WordPress blog, which goes into quite some detail on file permissions, as well as some other methods of securing WP.


Generally, it's never a good idea to have 777 set on anything. Read the links Thomas provided for more detail, but as a general rule 755 for folders and 644 for files is a good practice.

  • 1
    I thought if you wanted to use auto updating you needed to set some things to 777. And for sure you have to set the wp-content/uploads folder to 777.
    – tooshel
    Commented Aug 12, 2010 at 20:52
  • 3
    You don't need 777 for the wp-content/uploads folder. I have set it to 755. jamespaulp.us/wp-content/uploads/2010/08/uploadperm.png
    – James
    Commented Aug 14, 2010 at 18:28


I am not an expert on this, but I hear that there is no need for .htaccess if you are using newer versions of Apache (IIS had this feature for quite some time.) You can disable directory browsing in your Apache config. It is the Indexes option in the Options directive of the Directory directive.


I don't know if 777 is required by any. 755 is probably safe for content folders.


There are 3 type of users in apache, or almost any webserver users, groups, other

add user give him right permissions add him in webserver write permissioned group give him owner ship of web root ,

also see these to links

  • 2
    Can you try to expand your answer? Plus, that second sentence is very confusing.
    – s_ha_dum
    Commented Dec 29, 2012 at 15:45
  • in simple steps 1- add user in you apache server, sudo useradd -d /var/www -G www-data demo 2-set it password sudo passwd demo 3-Changing the document root permissions sudo chgrp -R www-data /var/www 4-change owner to the use chown -R demo /var/www 5-Make folder Group Writeable sudo chmod -R g+w /var/www 6- wordpress need all folders to be 755 and files to be 755 to do this recursivly use terminal for folders find /var/www -type d -exec chmod 755 {} \; for folders find /var/www -type d -exec chmod 644 {} \; also harden your securty with htaccess and other tricks that you can google Commented Dec 31, 2012 at 10:10
  • Edit your answer, please. That is hard to read in a comment. "group" is not a "user" as stated in your answer. Both /var/www/ and www-data are common but not universal. You are giving specific instructions that will not be applicable to everyone. That will cause confusion.
    – s_ha_dum
    Commented Dec 31, 2012 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.