我正在尝试使用密码保护文档根目录,但我得到的只是“内部服务器错误”页面。Apache 错误日志显示:
Invalid command 'AuthType', perhaps misspelled or defined by a module not included in the server configuration
在任何重写条目之前的我的 .htaccess 文件:
AuthType Basic
AuthName "Restricted Access"
AuthBasicProvider file
AuthUserFile /var/www/public/.htpasswd
Require user dean
我检查了模块是否已启用:
Array (
[0] => core
[1] => mod_so
[2] => mod_watchdog
[3] => http_core
[4] => mod_log_config
[5] => mod_logio
[6] => mod_version
[7] => mod_unixd
[8] => mod_access_compat
[9] => mod_alias
[10] => mod_auth_basic
[11] => mod_authn_file
[12] => mod_authz_core
[13] => mod_authz_groupfile
[14] => mod_authz_host
[15] => mod_authz_user
[16] => mod_autoindex
[17] => mod_cgi
[18] => mod_dav
[19] => mod_dav_fs
[20] => mod_deflate
[21] => mod_dir
[22] => mod_env
[23] => mod_filter
[24] => mod_mime
[25] => mod_negotiation
[26] => mod_php5
[27] => prefork
[28] => mod_reqtimeout
[29] => mod_rewrite
[30] => mod_setenvif
[31] => mod_socache_shmcb
[32] => mod_ssl
)
我的 Apache 版本是 Ubuntu 14.04 上的 2.4.10
答案1
似乎AuthType
由mod_authn_core
在 Apache 2.4 中。我没有看到您提供的列表中已加载该模块。
答案2
我正在使用Server version: Apache/2.2.15
,启动服务器时遇到了同样的错误。
我已经启用模块mod_authn_file
和mod_auth_basic
。现在运行正常!