Here's a summary that I have gathered
- chmod all files to 644
- chmod all .htaccess files to 644
- chmod all robots.txt files to 644
- chmod all directories to 711
- chmod all directories with directory listing (.htaccess Options +Indexes) to 755
- chmod all directories that users can upload files to, to 755 (ex: /uploads/).
Explanations:
- 644 means:
- 6: the owner of the file/directory can read and write, but not execute. Since files are not executable, you don't need to have "x" rights here (6 means r+w. 7 means r+w+x).
- 44: The group that the file/directory belongs to (see the group by using
ls -l
) and everyone else (the public) are able to read the file, but not execute or write to it (permission number 4).
- 711 means:
- 7: the owner of the file/directory can read, write, and execute. This is needed for directories! Without "execute" when you try to list the directory you'll get permission denied.
- 11: The group that the file/directory belongs to and the public have execute rights only. This is suitable for directories where you don't want other people browsing through the contents but do want to give them access to selected files further down the directory.
- 755 means:
- 7: the owner of the file/directory can read, write, and execute.
- 55: The group that the file/directory belongs to and the public have read and execute permissions but not write. This allows users to be able to view what files are in a directory, and be able to read those files, but not alter them.
There's also an interactive online calculator you can use to figure out what permissions to use: https://chmod-calculator.com/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…