SWatch Reader Favorite! WebDAV is turning into an important tool on Apache-based servers. Learn how to enable WebDAV on your Apache server and offer services like Apple's iCal to your users.
There is nothing worse when setting up a
website than having to build some complicated method of viewing and updating
the information on the site. There are lots of solutions -- using a local copy,
using a combination of HTTP and FTP tools to download the original and upload
the changes and of course the full-blown dynamic/content managed system that
provides that nice cuddly front end for you to enter the information into.
In order to simplify the way you update
websites, WebDAV was invented. Web-based Distributed Authoring and Versioning
(WebDAV) uses extensions to the existing HTTP protocol to enable multiple users
to manage and modify the files in a remote system. Using suitably enabled
clients you can view, open, edit and save files directly into the filesystem of
the Web site as it were of a remote website.
There are some obvious immediate
benefits of this, not least of which the ability to edit the website without
jumping through too many hoops, but it's the inventive use of the technology
beyond editing a remote website that has lead to a recent explosion in interest
of WebDAV. Nowhere is this explosion more prevalent than in the Mac OS X arena,
where the iCal calendar application, provided free by Apple, can publish
calendars to a WebDAV server so that other users can subscribe to the
calendars and find out what you're doing.
Enabling WebDAV on your Apache server is a
two stage process:
- You need to build and/or install the mod_dav module
to add WebDAV services to your Apache installation.
- You must make some
changes to your Apache configuration to tell it the directories in which to
enable WebDAV services.
For Apache 1.3.x under Unix you need the mod_dav module from http://www.webdav.org/mod_dav/,
the package you need is listed at the top of the main part of the page, or you
can download Version 1.3 using http://www.webdav.org/mod_dav/mod_dav-1.0.3-1.3.6.tar.gz.
Note that you'll need at least Apache version 1.3.6 to use the mod_dav module and it's best to use dynamic module loading rather than
having to recompile the Apache binary. Once you've downloaded the package and
extracted it using gunzip and/or tar, it should just be a case of:
That will copy the libdav.so module created into your apache's libexec directory, probably /usr/local/apache/libexec.
Mac OS X and Mac OS X Server should come
with the DAV module as part of the standard installation -- check the /usr/libexec/httpd directory for the libdav.so. If it
isn't there, follow the steps above for Unix to compile your own version.
For Apache 1.3.x under Windows, the same
site also provides a copy of a ready to run library to include (see http://www.webdav.org/mod_dav/win32/ for more
details). You'll need to download
the extension and then copy the module into the modules directory in your Apache installation.
For Apache 2.x a version of the mod_dav module is included. To ensure it's in your installation under Unix/Mac OS X you'll
need to recompile the Apache source, running the configure utility with the --enable-dav
option. Binary packages come with the module already enabled.
Windows versions of Apache 2 come with the mod_dav module.
Original date of publication, 04/07/2003
If you are using a statically built server you can skip over this bit. If you're using a dynamic setup, you must tell Apache to load
the corresponding DAV module. For Apache 1.3.x under Unix edit the httpd.conf file, find the
LoadModule section and uncomment or add the line:
LoadModule dav_module libexec/libdav.so
Under Windows you need:
LoadModule dav_module libexec/mod_dav.dll
Under Mac OS X you need:
LoadModule dav_module libexec/httpd/libdav.so
For Apache 2.x under Unix or Mac OS X, mod_dav you'll need:
LoadModule dav_module modules/mod_dav.so
Under Windows you need:
LoadModule dav_module modules/mod_dav.dll
The next steps are more complex, so we'll
take a little breather and find out exactly what is needed. To make use of
WebDAV you must provide the location of a lock file (using the DAVLockDB directive) which will be used to record which user has a particular
file open for writing or updating and prevents multiple users from trying to
write to the same file. You can also specify a timeout value; Apache will automatically
remove a lock if no access occurs during this period, the client specifies the requested timeout during connection, but you can override this using the
DAVMinTimeout directive. These first two settings
are handled by two lines in our httpd.conf file
that you can you place more or less anywhere; the first sets the lock file
location and the second the timeout value, in seconds:
I've used /tmp here for the lock file location, if you're particularly security conscious you
might to use a different directory which is more secure. Note as well that
these settings are global to the Apache server instance - we don't need to
specify different lock databases for different directories. You can, however, specify different timeout values for different directories just by embedding the
To enable individual directories with DAV
functionality we use a Location directive -- a
straightforward DAV directive tells Apache to
enable WebDAV on this location. We can also use the Location directive to enable security on the directory both to secure the
information we'll be storing and to prevent just anybody adding information to
our WebDAV enabled directory. The following block specifies the location of a
password file and limits everything but read operations from our directory
using the LimitExcept directive:
AuthName "WebDAV Restricted"
<LimitExcept GET HEAD OPTIONS>
Require user webdav
The last step is to create our password
file (unless we're using an existing one) and if necessary the directory we're
enabling with WebDAV:
chgrp www /export/http/webs/pri.mcslp/dav
chmod 775 /export/http/webs/pri.mcslp/dav
htpasswd -c /export/http/webs/pri.mcslp/dav/.DAVlogin webdav
Once all that is done, we need to restart
the Apache server to enable the new settings. Under Unix/Mac OS X we can do
this with apachectl:
Within Windows, use the Restart control option available from the Start menu.
Testing your Setup
If you are using Mac OS X, probably the easiest
way to test it is to share one of your calendars in iCal. Choose Publish from the Calendar menu, choose
Publish from a Web Server and enter the full URL of your server and DAV-enabled directory, then enter the username and password you set. Assuming
everything has gone correctly, you should have published your calendar to the
Under Windows, Windows 98, Me, 2000 and XP can all access a Web Share (the
Microsoft term for a WebDAV-enabled directory). Use the Add a Network Place
wizard, either through the links in the My Network Places window or through a
standard File Open/Save dialog and enter the URL - you'll be prompted for a
username and password.
Alternatively use a WebDAV enabled client
like JEdit. JEdit is Java based and happens to be a very good
editor. It also has a plug-in that allows
you to open and save files directly from and to a WebDAV folder.
Original date of publication, 04/07/2003