I have an "includes" directory that my web server should be able to fully interact with, but I don't want users to be able to see its contents.
feedback
|
|
Permissions on linux (which is what I assume you are using) are in the order:
U being user, the owner of the file. G being group access for a specific group, and O is other. If the users are not in a group that can access it and they are not the owners of the directory, they fall into the others category, so you only have to modify the last 3 fields. simplest way to do it:
or
770 will give owner and group full access, but take access from the "others". Its pointless to give them write and execute access though if they can't read it (needed to view contents) so you may as well use 770 chmod as opposed to 776 or the like. | |||||||||
feedback
|
|
You'll need to find the user or group your webserver runs as, and then
or something similar. This assumes that you mean local users :) if you mean web users, then you'll have to bear in mind that anonymous web users have exactly the same permissions as your web server, necessarily. | ||||
feedback
|
|
You probably want to use an htaccess file to limit viewing permission of that folder, but read Apache's documentation on the subject for other, better alternatives. | ||||
|
feedback
|
|
Put the includes directory outside of your web site root directory. You don't want it under your content directory since the web server can then serve it to site users. So if your web site root is
| ||||
|
feedback
|
|
@jeremy (since I don't have the rep to comment on his answer): You don't want to chmod 660 a directory, because that will give the owner and group permission denied errors and/or strange output. e.g.`
I forgot to show this part.
` | ||||
|
feedback
|
|
Assuming that you want web server processes to be able to read and write files in (but not serve up content from) the directory, you want to
If your web server runs as nobody (an unprivileged user that some distributions run multiple server processes under), bear in mind that other processes running as this user may be able to get at the directory as well. If this is a problem, you may want to create a dedicated user for your web server. This will entail changing the web server config and/or startup scripts in addition to creating the user and group. Since I'm recommending mode 0700, the group is technically not important, but you have to remember that the web server may create files with wider permissions (664 or 775) inside of this directory if the umask of the web server user is set to 002 instead of the more-common 022. A dedicated group will ensure that such files are not inadvertently opened up to writes by other members of a shared group that you might stick the web server user in. | ||||
|
feedback
|
|
Make sure your web server runs as a user with limited permissions and with a restricted group as its group. Then make sure the files are accessible only by the user and/or group, by removing public read and execute access (public write access should almost never be granted). Those who maintain the site also need access to the material - preferably not by wielding superuser privileges. That may alter the way you do things. Consider whether ACLs are appropriate - these would allow you to provide the web server group with read access to the files, the maintenance group with read and write access, and still deny the general public access. Without ACLs, you can only have one set of group privileges. | ||||
|
feedback
|
|
If you remove read privileges they won't be able to see what files are there. (If you remove execute privileges, then they can't cd to it.) | ||||
|
feedback
|
|
The 'x' (execute) bit on a directory in Linux/Unix is the one that controls whether you can list the contents of it. | |||||
feedback
|