我有一台 raspberry pi 1,它使用 apache 2.22 提供网页。我做了一些研究,找到了一种使用数据库(在本例中为 mysql)保护“页面”的方法。
我发现这让它工作的小指南(也检查了官方文档)。创建了一个名为 apache 的数据库和一个名为 password 的表(与指南中相同)。然后,我将与数据库相关的配置内容添加到我的网站的配置文件。这是代码片段:
DBDriver mysql
DBDParams "host=localhost port=3306 dbname=apache user=myuser pass=mypass"
DBDMin 2
DBDKeep 4
DBDMax 10
DBDExptime 300
...
# A virtualhost
<VirtualHost *:80>
ServerName subdomain.domain.com
ServerAdmin [email protected]
<Location />
AuthName "Identification to my page"
AuthType Basic
AuthBasicProvider dbd
# Also tried this line, replacing the other AuthDBDUserPWQuery below, but no luck
#AuthDBDUserPWQuery "SELECT encrypt(password) AS password FROM password WHERE username=%s"
AuthDBDUserPWQuery "SELECT `password`.`password` FROM `apache`.`password` WHERE `password`.`username`=%s"
Require valid-user
</Location>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.5:32400/"
ProxyPassReverse "/" "http://192.168.1.5:32400/"
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteRule ^/plex/$ /web/$1 [P]
</VirtualHost>
...
当我输入 subdomain.domain.com 时,页面请求用户名和密码,但之后,我得到此页面:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.22 (Debian) Server at subdomain.domain.com Port 80
因此,问题很简单,我做错了什么?如何使 mysql auth 在这里工作?
先感谢您。
编辑1:
我将 raspbian 从 wheezy 更新到 jessie,现在我安装的是 Apache Httpd 2.4,而不是 2.22。
有人可以提供一些快速解释,使数据库(mysql 或 postgresql)授权在 VirtualHosts 上工作吗?