Randy, I will try and address each point below.
I appreciate that info. I did that. /des is now owned by nobody (which is the >server user on Apache). Having an ownership of nobody on /des allows the php >code to mkdir() under it. However, I can view this directory from a browser. I >have used various combinations of permissions and wonder if they have any >effect since the owner is nobody. My questioning is based on this statement:
Apache runs as a special user called nobody. This means that for Apache to >serve up your Web pages to visitors, the files either need to be readable to the >world, or they need to be owned by the nobody user.
First of all when you say that the directory /des is viewable through the browser it kind of scares me a little. The reason is that /des would indicate that it would be off of the ROOT directory of your server. What do you have set as your document root in your apache httpd.conf? I hope you meant that you had a directory like http://myserver.com/des and on your file system it is really /my/web/stuff/des 🙂
Q1. Is it standard practice for all my pages and directories to be owned by >(nobody)?
No, it is not a standard practice to do so. Usually ownership is left as the user/group that created the file and you merely add o+r to the file in order to make it world readable (and thus by the nobody user running the webserver).
Q2. My goal is to have my pages served, my php functions like mkdir() to work, >and none of my directories viewable. Maybe I am asking too much of this >user/permission stuff. Maybe the solution is to place an index.html in every >d....
There are options inside of apache that tell it whether or not to display the directory contents when you browse to a directory without specifying a file and it does not have an index.html file in it. If I recall it is "Allow Indexes" and it can be placed inside <Directory> blocks in the httpd.conf. If you never want directories browsable then you can remove that.
If you want to "cheat" you can make your directories with only o+x instead of o+rx which allows the files in the directory to be read (assuming they are set as mentioned above) but it will not allow the directory to be displayed if there is no index.html file.
When you want functions to read/write to the file system and you are using the mod_php DSO then you have to make them owned/grouped by the nobody user or you have to make them world read/write. The latter is not the best option by far.
If you want to guarantee that the files in the directories for uploads or whatever are not accessible through the web you can place them outside of your apache document root. That way you cannot put in any URL that would access the directory, but the server process could still read/write from the directory.
Q3. A related question. I have a directory /phpMyAdmin This is a front end to >my databases. I want a password dialog to come up when I access it. This >used to work on my old server which used .htaccess files. My new unix apache >server does not seem to have this. I have looked in all the user guides. How >can I accomplish this?
You need to use .htaccess files. If you find that you put the files in the directory but the prompt does not come up for you, then you will need to check your httpd.conf and make sure you have "AllowOverride AuthConfig" inside of the <Directory> block where you want to use it.
You will want to browse the Apache docs for those sorts of things and look for the directives I have mentioned. I know it can be confusing and hard to find when you don't quite know what to look for. There are also most likely similar postings on these forums. I know there are plenty on "how to protect your files" from being viewable via the web.
I hope that answers some of your questions.
Tim Frank