如何在SQL Server(ODBC)中使用mod_authn_dbd [英] How to use mod_authn_dbd with SQL Server (ODBC)
本文介绍了如何在SQL Server(ODBC)中使用mod_authn_dbd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有许多关于在MySQL上使用 mod_authn_dbd 的教程但是我找不到使用ODBC的SQL Server.我花了一段时间才弄清楚,所以我决定在这里写下来.这不是一个完整的教程,但足以使您入门并开始工作.
There are many tutorial for using mod_authn_dbd with MySQL but I could not find any with SQL Server using ODBC. It took me a while to figure it out, so I decided to write it up here. It's not a full blown tutorial but it should be enough to get you up and running.
推荐答案
所有命令都必须以root用户或使用sudo来运行.
All commands must be run as root or using sudo.
为Linux安装Microsoft ODBC驱动程序
Example for Debian 9:
apt update
apt install curl apt-transport-https
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt update
ACCEPT_EULA=Y apt-get install msodbcsql17
配置/etc/odbc.ini
示例内容:
[DBSERVER1]
Driver = ODBC Driver 17 for SQL Server
Server = 192.168.1.123
安装并启用mod_authn_dbd
apt install libaprutil1-dbd-odbc
a2enmod dbd
a2enmod authn_dbd
a2enmod authn_socache
配置Apache身份验证
将此添加到您的网站配置中的某个位置:
Add this somewhere in your site config:
DBDriver odbc
DBDParams "DATASOURCE=DBSERVER1,USER=dbuser,PASSWORD=dbpass"
<Location "/test">
AuthType Basic
AuthName "Secured area"
AuthBasicProvider socache dbd
AuthnCacheProvideFor dbd
AuthnCacheContext my-server
Require valid-user
AuthDBDUserPWQuery "SELECT USR_PASS FROM USERS WHERE USR_EMAIL=%s"
</Location>
这篇关于如何在SQL Server(ODBC)中使用mod_authn_dbd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文