Django站点上的Apache基本身份验证

时间:2010-02-10 16:58:45

标签: django apache

我正在尝试将基本的Apache名称/密码身份验证添加到正在运行的Django站点。

我关注example here。我已经创建了一个.htpasswd文件,并在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>

但是,当我尝试启动Apache时,收到错误消息:

[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

我做错了什么?据我所知,这是所有例子的精确副本。

我不需要指定要保护的路径 - 只需整个网站就可以了。我不完全确定要放入<Directory&gt;虽然标记 - 我的Django项目的根,Apache的根(如此处),还是别的什么?

2 个答案:

答案 0 :(得分:2)

来自http://readthefuckingmanual.net/error/1385/(我没有故意选择该网址,我发誓!):

确保在httpd.conf中有这个:

LoadModule authn_file_module modules/mod_authn_file.so

答案 1 :(得分:0)

AuthUserFilemod_authn_file的一部分,仅在2.1中提供。确保模块已加载(如果存在)。如果没有......你将无法使用该指令。