How to use mod_authn_dbd with SQL Server (ODBC)

坚强是说给别人听的谎言 提交于 2020-02-07 04:13:09

问题


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.


回答1:


All commands must be run as root or using sudo.

Install Microsoft ODBC drivers for Linux

Instructions on Microsoft site

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

Configure /etc/odbc.ini

Example content:

[DBSERVER1]
Driver = ODBC Driver 17 for SQL Server
Server = 192.168.1.123

Install and enable mod_authn_dbd

apt install libaprutil1-dbd-odbc
a2enmod dbd
a2enmod authn_dbd
a2enmod authn_socache

Configure Apache authentication

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>


来源:https://stackoverflow.com/questions/56797009/how-to-use-mod-authn-dbd-with-sql-server-odbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!