This page guides you through installing and setting up apache2 on Ubuntu Hoary with WebDAV, MySQL authentication and mod_auth_user_dir. Once completed, this setup allows your server to act as a fileserver to a wide range of clients from almost anywhere as it can be hosted on the internet.
First download and install the required packages by using apt-get. Make sure that the universe repository is enabled in your /etc/apt/sources.list
sudo apt-get install apache2 \ apache2-threaded-dev \ libapr0-dev \ libapache2-mod-auth-mysql \ libapache2-mod-dav \ automake1.4 sudo apt-get build-dep apache2
Download the mod_auth_user_dir to a safe place (/usr/src) and unpack it
sudo wget http://www.genos.org/downloads/mod_authuserdir-1.0.tgz /usr/src cd /usr/src tar -xzvf mod_authuserdir-1.0.tgz cd mod_auth_user_dir
Next download the first patch and the second patch and place it in the current directory:
sudo patch -p1 < Makefile.am.patch sudo patch -p1 < configure.in.patch
Then run the configuration programs.
sudo aclocal sudo autoconf sudo automake -a sudo ./configure --with-apache=/usr/include/apache2 make sudo apxs2 -i -a -n auth_user_dir libmod_auth_user_dir.la
apxs2 does things that are not considered the "debian" way. It appends a module load line into /etc/apache2/httpd.conf. It is really suppose to create a file under /etc/apache2/mods-available/ and then the user is suppose to use a2enmod to enable it. It bothers me so I copied the line out of httpd.conf and created a new file. It may not bother you so this is just a warning.
Enable all of the necessary modules, in order to make this work.
sudo a2enmod auth_mysql sudo a2enmod dav sudo a2enmod dav_fs
At this point you just have to edit your site's configuration. Below is an example working configuration.
Note: you have to create the user directories in the file system under the root user directory (in the case below /var/www/users) in order for this module to work correctly. It DOES NOT generate them on the fly. Also the directories have to modifable by the webserver otherwise your users will not be able to upload files.
<Directory /var/www/users> DAV On AuthUserDirRoot "/var/www/users/" AuthName "Secure Login" AuthType Basic AuthMySQL On AuthMySQL_Host (database hostname) AuthMySQL_DB (database name) AuthMySQL_User (database username) AuthMySQL_Password (database password) AuthMySQL_Password_Table (table name) AuthMySQL_Username_Field (column name of username) AuthMySQL_Password_Field (column name of password) AuthMySQL_Group_Field (column name of group) AuthMySQL_Group_Table (table name in which groups are located) AuthMySQL_Encryption_Types PHP_MD5 (for md5 hashes with lower case letters) <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> require valid-user </Limit> </Directory>