Sql server 如何将mod_authn_dbd与SQL Server(ODBC)结合使用
有很多关于MySQL的教程,但我找不到任何关于SQL Server使用ODBC的教程。我花了一段时间才弄明白,所以我决定把它写在这里。这不是一个完整的教程,但应该足以让您启动并运行。所有命令都必须以root用户身份或使用sudo运行 为Linux安装Microsoft ODBC驱动程序 Debian 9的示例:Sql server 如何将mod_authn_dbd与SQL Server(ODBC)结合使用,sql-server,apache,authentication,odbc,Sql Server,Apache,Authentication,Odbc,有很多关于MySQL的教程,但我找不到任何关于SQL Server使用ODBC的教程。我花了一段时间才弄明白,所以我决定把它写在这里。这不是一个完整的教程,但应该足以让您启动并运行。所有命令都必须以root用户身份或使用sudo运行 为Linux安装Microsoft ODBC驱动程序 Debian 9的示例: apt update apt install curl apt-transport-https curl https://packages.microsoft.com/keys/mic
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
配置Apache身份验证
在站点配置中的某个位置添加以下内容:
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>
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>