apache virtual host:
DBDriver mysql DBDParams "host=1.2.3.4 port=3306 dbname=dbname user=dbuser pass=dbpass" DBDMin 1 DBDKeep 1 DBDMax 10 DBDExptime 200 <Location /> AuthType Basic AuthName "Realm" AuthBasicProvider socache dbd AuthnCacheProvideFor dbd AuthnCacheContext some-ctx Require valid-user AuthDBDUserPWQuery "SELECT passhash FROM users WHERE username = %s LIMIT 1" </Location>
sudo apt-get install apache2-dev libapr1-dev libaprutil1-dev libapr1 libapr1-dev libaprutil1-dbd-mysql
a2enmod dbd cache_socache socache_shmcb authn_dbd authn_socache
service apache2 reload