Forum Moderators: phranque

Message Too Old, No Replies

Issue with Apache 2.2 on Windows

changing "DocumentRoot"?

         

Mystical Ice

3:57 pm on Jan 21, 2008 (gmt 0)

10+ Year Member



Hi
I just installed Apache2.2 on Windows XP. I got the "it works!" page, but when I try changing the "DocumentRoot" in the httpd.conf to another directory, say, to "D:\MP3\" (my personal MP3 directory), then I get a "Forbidden" error when I load the page from another computer, or when I load it from the same computer the server's running on (127.0.0.1) i get the "you do not have permission to view this page" windows error message

The error log has this error:
[Mon Jan 21 09:37:24 2008] [error] [client 127.0.0.1] client denied by server configuration: D:/MP3/

I guess i don't have permission? How do I change that? :( I can't find why!

gergoe

4:19 pm on Jan 21, 2008 (gmt 0)

10+ Year Member



If you continue reading the httpd.conf file after modifying the DocumentRoot, you'll find a section which talks about the permissions of the root folder, and you'll find the following sentence there:

This should be changed to whatever you set DocumentRoot to.

So it is not enough just to modify your DocumentRoot, but you have to tell Apache that it can serve files from that directory (by default everything is denied).

Mystical Ice

8:37 pm on Jan 21, 2008 (gmt 0)

10+ Year Member



aww man that did it! thanks a lot! :)

One more question; if i want to enable some sort of .htaccess on my root directory, how would i go about doing that? i found a couple of tutorials, but they didn't help (i guess windows and the linux versions are different or something).

i just want a password prompt to come up on the root directory. i'm familiar with creating the .htpasswd files.

how would i do that?

Thanks in advance :)

coopster

8:40 pm on Jan 21, 2008 (gmt 0)

gergoe

11:45 pm on Jan 21, 2008 (gmt 0)

10+ Year Member



You can do it in the server config as well, same way as in the case of .htaccess files, but you need to enclose the Auth* directives in a <Directory> container.

For example:

<Directory D:/MP3> 
# The Apache directives goes here,
# and will be only applied to the D:/MP3 directory
</Directory>

gergoe

11:53 pm on Jan 21, 2008 (gmt 0)

10+ Year Member



...and if you really want to go on with .htaccess files in general, you'll need to enable them by defining the
AllowOverride All
directive in your httpd.conf (within the same <Directory> container you already modified).

Mystical Ice

4:50 am on Jan 22, 2008 (gmt 0)

10+ Year Member



Thanks for the responses; I really appreciate it.

I feel like a real noob, but here's what i did, and i can't figure this out:

====================================

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

#
# 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:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org...]
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

====================================

I've tried putting the following code practically everywhere, but the service fails to start each time.

AuthType Basic
AuthName "Restricted Files"
AuthUserFile C:\Program Files\Apache Software Foundation\Apache2.2\bin\neri
Require user neri

Where exactly should i place it, and is it in the right format? :-/

Mystical Ice

6:42 pm on Jan 25, 2008 (gmt 0)

10+ Year Member



anyone? :-/

coopster

11:13 pm on Jan 25, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Reread the last two posts by gergoe carefully. Also, any Windows paths like that with spaces in them should be surrounded with quotation marks.
AuthUserFile "C:\Program Files\Apache Software Foundation\Apache2.2\bin\neri"