Long story short, due to political (licensing) reasons, MySQL support was removed from Apache’s APR base. Here’s how to get it back and fix a few bugs in the default driver (the default causes it to die with various named virtualhosts):

First, ensure you have the ability to build all of the requirements:

# apt-get build-dep libaprutil1 libaprutil1-dev

Then, install the libmysqlclient support (the new MySQL 5 driver):

# apt-get install libmysqlclient15-dev wget apache2.2-common

Get the necessary driver

# apt-get source apr-util
# cd ./apr-util-1.2.7+dfsg/dbd
# wget 'http://apache.webthing.com/svn/apache/apr/apr_dbd_mysql.c'
# cd ..

Get the timeout patch.

  1. wget ‘http://issues.apache.org/bugzilla/attachment.cgi?id=20479’ -o apr.patch

  2. patch < apr.patch
    Build libaprutil1.

    # vi debian/rules

    .. add —with-mysql=/usr to the configure line ..

    # (fakeroot) debian/rules binary

    Install APR (add dev if required.)

    # dpkg -i ../libaprutil1_1.2.7+dfsg-2_i386.deb \
       ../libaprutil1-dev_1.2.7+dfsg-2_i386.deb

    Get the Apache source

    # apt-get source apache2
    # cd apache2-2.2.3/modules/database/

    Update the database driver

    # wget 'http://svn.apache.org/viewvc/httpd/httpd/trunk/modules\
    /database/mod_dbd.c?view=co'
    # mv 'mod_dbd.c?view=co' mod_dbd.c

    Build the new Apache:

    # cd ../..
    # (fakeroot) debian/rules binary

    Install the new Apache (I need PHP, so I use prefork):

    # dpkg -i ../apache2-mpm-prefork_2.2.3-4_i386.deb \
       ../apache2-utils_2.2.3-4_i386.deb

Now, go ahead and enable it, then restart:

#ln -s /etc/apache2/mods-available/dbd.load /etc/apache2/mods-enabled/
#/etc/init.d/apache2 restart

You may wish to tag your custom Apache to keep it from being overwritten by standard apt upgrades:

#for n in libapr1 libapr1-dev libaprutil1 \
libaprutil1-dev apache2-mpm-prefork \
apache2-utils apache2.2-common; do echo $n hold | \
dpkg --set-selections; done

You’re all set!

[Edit: When I wrote this initially, I was thinking of an older way to flag packages with apt; the proper way is to set them with dpkg. Thanks to Bart Cilfone for noticing my err.]

[Edit 2: A clarification by Stephan Jansen appended for your information (steps above modified): The mod_dbd.so is located in the apache2.2-common package, so this needs to be install also.
Another issue: There is a bug in apr-util which causes authentication to fail after an mysql-connection timeout occures (default: 8 hours of inactivity). The Patch at bug #42841 resolved this problem for me.]

Previous Post Next Post