I'm trying to add basic Apache name/password authentication to a running Django site.
我正在尝试向正在运行的Django站点添加基本的Apache名称/密码身份验证。
I've following the example here. I've created an .htpasswd file and have the following in httpd.conf:
我已经遵循了这个例子。我创建了一个.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>
However, when I try to start Apache, I get the error message:
但是,当我尝试启动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
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?
我不需要指定要保护的路径——只需整个站点就可以了。我不太确定要在
2 个解决方案
#1
2
From http://readthefuckingmanual.net/error/1385/ (I didn't pick that URL intentionally I swear!):
从http://readthefuckingmanues.net/error/1385/(我没有故意选择URL,我发誓!)
Make sure you have this in your httpd.conf:
请确保您的httpd.conf:
LoadModule authn_file_module modules/mod_authn_file.so
#2
0
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.
AuthUserFile是mod_authn_file的一部分,它只在2.1中可用。如果模块存在,请确保模块已被加载。如果它不…你不能用那个指令。
#1
2
From http://readthefuckingmanual.net/error/1385/ (I didn't pick that URL intentionally I swear!):
从http://readthefuckingmanues.net/error/1385/(我没有故意选择URL,我发誓!)
Make sure you have this in your httpd.conf:
请确保您的httpd.conf:
LoadModule authn_file_module modules/mod_authn_file.so
#2
0
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.
AuthUserFile是mod_authn_file的一部分,它只在2.1中可用。如果模块存在,请确保模块已被加载。如果它不…你不能用那个指令。