【问题标题】:Turning on Apache Basic Auth causes server connection failure开启 Apache Basic Auth 会导致服务器连接失败
【发布时间】:2011-10-07 04:06:13
【问题描述】:

我正在尝试测试 apache httpd Web 服务器的基本身份验证模块。由于某种原因,当我打开它时,浏览器似乎甚至无法连接到服务器。详情如下。任何帮助将不胜感激。

OS: Mac OSX
Apache/Mysql
Browser: Safari

我有一个mysql db“mydb”将用户名和密码存储在一个名为“login”的表中。密码使用 SHA 加密。

我有一个类似的目录结构

/Users/Myname/Sites
/Users/Myname/Sites/Secret

我想保护 Secret 文件夹。

在 httpd.conf 我有以下几行

DBDriver mysql
DBDParams "dbname=mydb user=admin password=myadminpasswd"

DBDMin  4
DBDKeep 8
DBDMax  20
DBDExptime 300

<Directory "/Users/Myname/Sites/Secret">
 # core authentication and mod_auth_basic configuration                                                                                                                     
  # for mod_authn_dbd                                                                                                                                                       
  AuthType Basic
  AuthName "My Server"
  AuthBasicProvider dbd

  # core authorization configuration                                                                                                                                        
  Require valid-user

  # mod_authn_dbd SQL query to authenticate a user                                                                                                                          
  AuthDBDUserPWQuery "SELECT password FROM login WHERE username = %s"
</Directory>

在此之后我重新启动 apache httpd 服务器。我什至无法再访问http://localhost。 它给出了以下错误: Safari 无法打开“http://localhost/”页面,因为 Safari 无法连接到服务器“localhost”。

我希望能够访问 localhost 但不能访问http://localhost/~myname/Secret

有人知道出了什么问题吗?

我相信我可以通过以下方式访问秘密文件夹 http://mysername:mypasswd@localhost/~myname/Secret

注意:我已确保 httpd.conf 中加载了以下内容

mod_authz_user.so
mod_authn_dbd.so

谢谢 mbh

【问题讨论】:

    标签: mysql macos apache mamp basic-authentication


    【解决方案1】:

    请检查您的 apache 服务器日志并查看在启用身份验证的情况下重新启动它时遇到的错误

    【讨论】:

    • 在mac网络共享中,它是绿色的,它表示服务器正在运行。但是当我查看错误日志时,我发现它根本没有启动。也没有错误。我删除了所有的身份验证代码。然后它工作。排错,即使我有第一行:DBDriver mysql - The server doesn't start according to the error log
    猜你喜欢
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    • 2016-06-12
    相关资源
    最近更新 更多