We help IT Professionals succeed at work.
Get Started

protecting a directory with .htaccess & mysql

mark2326 asked
Last Modified: 2013-11-11
My goal is to have a directory password protected, and have the usernames and passwords stored in mysql.
After a little reading mod_authn_dbd sounded like what I needed.
I enabled the module and other associated with it.
I configured my .htaccess as follows.. and put it into the directory I'm trying to protect...

# mod_dbd configuration
DBDriver mysql
DBDParams "host= port=3306 dbname=test user=root password=my_password"

DBDMin 1
DBDKeep 8
DBDMax 20
DBDExptime 300

<Directory /Volumes/MacHD/webSite/Subscriber/>
# core authentication and mod_auth_basic configuration
# for mod_authn_dbd
AuthType Basic
AuthName "subscriber"
AuthBasicProvider dbd

# core authorization configuration
Require valid-user

# mod_authn_dbd SQL query to authenticate a user
AuthDBDUserPWQuery \
"SELECT password FROM password WHERE user = %s"

when I go to that directory in a web browser I get a Server error 500. My Apache error logs give me this error ".htaccess: DBDriver not allowed here"

According to http://httpd.apache.org/docs/2.2/mod/mod_dbd.html#dbdriver I need the driver "apr_dbd_mysql.so.".
I'm assuming all the necessary APR's came with Apache??

I'm running an Xserve OS 10.6.3 server, Apache 2.2.14,  mysql 5.0.88

Any ideas? Thank you.

Watch Question
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE