Fixing apache file and directory permissions


I’ve seen this problem a few times, people having trouble getting the permissions right for websites. Heres a quick fix that will sort you in most cases

For directories run
find /path/to/domain/public_html/ -type d -print0 | xargs -0 chmod 755

Files run this one
find /path/to/domain/public_html/ -type f | xargs chmod 644

Make sure you change the path to be the correct path, and remember that some applications require a little more work.  If you get stuck just drop us an email into  support.


2 responses to “Fixing apache file and directory permissions”

  1. I hadn’t throught about doing it that way. I would normally use:

    chmod -R u=rwX,go=rX /path/to/domain/public_html/

  2. Note to self:

    X (capital x) means “execute/search only if the file is a directory or already has execute permission for some user”

    u=blah or u+blah has always been my preferred way of setting permissions. Since it avoids needing to work in octals (have enough trouble with decimal).