Guides Enabling WebDAV on Apache Page 2

Enabling WebDAV on Apache Page 2




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:

DAVLockDB /tmp/DAVLock
DAVMinTimeout 600

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
DAVMinTimeout.

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:

    DAV On
    AuthType Basic
    AuthName "WebDAV Restricted"
    AuthUserFile /export/http/webs/pri.mcslp/dav/.DAVlogin
    
        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:

mkdir /export/http/webs/pri.mcslp/dav
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:

apachectl restart

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
WebDAV share.

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

Latest Posts

Related Stories