WebDAV on Apache 2.x
|Line 9:||Line 9:|
### WebDAV settings
### WebDAV settings
Revision as of 22:58, 17 October 2004
Apache 2.x, as installed from the ports tree, has modules installed already to allow WebDAV functionality - all you have to do is un-comment the proper lines in the LoadModules section of your httpd.conf, and then add some lines later on in it for basic configuration of the WebDAV location(s).
First of all, make sure the following lines are present and uncommented in /usr/local/etc/apache2/httpd.conf:
LoadModule dav_module libexec/apache2/mod_dav.so LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
Now skip to the end of httpd.conf (actually you can put these lines anywhere, but for our purposes we're going to tack all the WebDAV configs onto the end in one block so we can easily find them later) and put in the following:
### WebDAV settings DAVLockDB /tmp/DAVLock DAVMinTimeout 600 <Location /WebDAV/> DAV On AuthType Basic AuthName "WebDAV Restricted" AuthUserFile /usr/local/www/.DAVlogin <LimitExcept GET HEAD OPTIONS> Require valid-user </LimitExcept> </Location>
The DAVLockDB attribute tells Apache where to put the lock file for WebDAV functionality, which is how it keeps track of which users have writes pending to which DAV-enabled files and directories. In this case, we've placed it in /tmp, which is generally a perfectly reasonable place to do so. DAVLockDB and DAVMinTimeout are generally system-wide attributes, and only need to be specified once for the entire server - although if you place them within a <Location>, they can override the system-wide settings, if for some reason you did want to specify separate lock files and/or timeout values for that one particular <Location>.
The <Location> we've defined in the above example should be fairly self-explanatory - it allows DAV functionality within the web directory /WebDAV/, and requires a valid user from the password file at /usr/local/www/.DAVlogin in order to allow any DAV or HTML PUT operations.
Now that we've defined everything in httpd.conf, we just need to create the directory we want to use, make sure the permissions and ownership are set properly, create our user auth file, and restart Apache.
ph34r# mkdir /usr/local/www/data/WebDAV ph34r# chown www /usr/local/www/data/WebDAV ph34r# chgrp www /usr/local/www/data/WebDAV ph34r# chmod 775 /usr/local/www/data/WebDAV ph34r# htpasswd -c /usr/local/www/.DAVlogin dav-user password: Re-type new password: Adding password for user dav-user ph34r# apachectl restart ph34r#
And there we have it; we've now got WebDAV running, turned on at /WebDAV/, with everything we need to allow a user named dav-user with whatever password we specified to read and write inside that directory via DAV functionality. One of the more common current uses for this is to enable calendar sharing using iCal, Sunbird, or Mozilla Calendar.