Sunday, January 25, 2009

After I install Apache, why am I forbidden from hitting any page in my webroot?

Now there are a lot of possible answers to this question, but I searched Google for quite some time looking for answers. Everyone mentioned checking the permissions on the folder, which is good advice, you should start there. But I don't know much about permission and everything seemed to look okay and still nothing. Since I was migrating from IIS to Apache, I already had my webroot setup to work with IIS and that worked fine, so I was a bit at a loss for what was wrong. Well, the problem I had at least ended up being in the httpd.conf file. Of course I had changed my DocumentRoot to:

DocumentRoot "C:/www"

but it turns out there is another place in the httpd.conf where you need to update the webroot about 30 lines down. There was a nice comment above the code that said it needed to be changed, so this is yet another reason to at least skim through the configuration file. Anyway, I edited that line and voila, everything works. Here in the line I edited along with the comment above it:


#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/www">


Here's to hoping this saves someone some time and also a reminder to read through the configuration or ini files once. Yes, it's tedious and often boring, but you always learn something and it can keep you from wasting an hour like I did.

Also, if anyone is wondering, I'm running Apache 2.11. It's probably a good idea to search through the httpd.conf file for references to "htdocs" since that's where the default webroot is located in case future versions include references to your document root elsewhere.

No comments: