Apache 2.2 mod_dbd MySQL user authentication
Building Apache 2.2.x:
Although it says you can enable mysql for Apache 2, hidden secretly is a document that informs you that it is not actually distributed with it due to licensing issues (the GPL is not compatible with Apache’s license). So in order to use mysql you need to do a few things before compiling. In the apache2 source directory do the following:
% cd srclib/apr-util/dbd/ % curl -O http://apache.webthing.com/svn/apache/apr/apr_dbd_mysql.c % cd ../../.. % ./buildconf
Now apache will be all configured to use it. Simply add ”–enable-dbd –enable-authn-dbd –with-mysql=/path/to/your/mysql” to the configure command and you’ll be all set to go.
Now in the httpd.conf file, you can use the normal stuff suggested in the apache documentation. The only weird thing is the AuthDBDUserPWQuery documention saying “The query must take a single string (typically SQL varchar) argument (username), and return a single value (encrypted password)”. What this means is your database will have to have the password encrypted using the mysql encrypt() command. You can either store it this way or encrypt it on retrieval by setting AuthDBDUserPWQuery to “SELECT encrypt(password) FROM authn WHERE username = %s”.
Unfortunately, it does not seem possible to use it with any other encryption mechanisms.