tags:

views:

48

answers:

2

I'm trying to add basic Apache name/password authentication to a running Django site.

I've following the example here. I've created an .htpasswd file and have the following in httpd.conf:

WSGIScriptAlias / /home/ann/webapps/django/domesday.wsgi
<Directory /home/ann/webapps/apache2>
AuthType Basic
AuthName "Authentication Required"
AuthUserFile "/home/ann/webapps/django/domesday/.htpasswd"
Require valid-user
</Directory>

However, when I try to start Apache, I get the error message:

[annaps@web121 apache2]$ bin/restart 
Apache isn't running.
Syntax error on line 25 of /home/annaps/webapps/django/apache2/conf/httpd.conf:
Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration

What am I doing wrong? As far as I can tell, this is an exact copy of all the examples.

I don't need to specify paths to protect - just the whole site is fine. I'm not totally sure what to put in the <Directory> tag though - the root of my Django project, the root of Apache (as here), or something else?

A: 

From http://readthefuckingmanual.net/error/1385/ (I didn't pick that URL intentionally I swear!):

Make sure you have this in your httpd.conf:

LoadModule authn_file_module modules/mod_authn_file.so
jathanism
Thank you. That solves the error message but unfortunately I now have a 500 error. If I comment out the <Directory> part it goes away. Any ideas? :(
AP257
Have you checked the error logs for the server? What do they say?
jathanism
A: 

AuthUserFile is part of mod_authn_file, which is only available in 2.1. Make sure that the module is loaded if it exists. And if it doesn't... you won't be able to use that directive.

Ignacio Vazquez-Abrams