[Previous entry: "Revenge of popfile: Dude, where's my buckets?!"] [Next entry: "PHP: pass by value/pass by reference"]
09/27/2004: "File permissions and HTTPD"
Hey, folks. Here's a good tip.
Let's say you want to test your web site on your own box, and let's say you always want to use Eclipse while you're building your site. In this case, there's a good chance your Eclipse workspace is in your home directory. For me, that's /home/jbrains. Now in there you'll have a folder containing your project, within which you might have a folder called www containing the web pages. You now want Apache to serve up those pages.
Easy, right? Open httpd.conf, change the DocumentRoot to /home/jbrains/workspace/..., then restart Apache and you're done, right?
Not so, for me. I get Permission denied /. Why is Apache going to the root of my file system?!
Well, the short version is this: it isn't. Remember that Apache will operate under the user name apache by default, and so you must be careful with both file and directory permissions. In my case, /home/jbrains was owned by user jbrains and only accessible by the owner. Poor old user apache didn't stand a chance. Once I fixed that problem, I could see my web page!
So here's the tip: know what user an application is running with, and check directory permissions everywhere for that user.
