August 17, 2007

Turn Apache into a collaborative authoring platform with mod_dav

Author: Murthy Raju

Ever thought about how nice it would be if you could edit the files stored on your Web server directly without the cumbersome download-edit-upload routine? Web-based Distributed Authoring and Versioning (WebDAV) is the way to do it. A WebDAV server works like a file server that uses HTTP as the underlying protocol. It facilitates collaborative editing and versioning. If you manage a Web server or an enterprise document management system, where different authors need to edit resources, WebDAV is a useful way of providing write access to them. You can use the Apache modules mod_dav and mod_dav_fs for basic WebDAV functionality, while a Subversion module for Apache, mod_dav_svn, provides versioning support.

WebDAV is a set of extensions for HTTP that facilitate collaborative Web authoring. It extends HTTP by adding methods for operations such as locking and unlocking, setting properties, searching based on a property, and deleting. Properties are the metadata that describe the resource; they can be any arbitrary key-value pairs. For instance, a resource may have a property called "TargetAudience" with a value "Accounts Department Staff." Versioning support is designed as an extension to WebDAV for maintaining different versions of the same resource on a server. Versioning support for WebDAV is popularly known as Delta-V.

Here are some of the major features of WebDAV:


  • File download and upload
  • Overwrite protection through locking
  • Information about the resource (metadata) on the server stored as a collection of properties
  • Copy or move the resource on the server
  • Access control
  • Searching


  • Check in, check out, cancel check out, update
  • Version control
  • Version reports
  • Merge

Setting up your Apache server for basic WebDAV functionality is fairly straightforward. mod_dav and mod_dav_fs are bundled with Apache and are installed by default. You can have WebDAV functionality up and running in three simple steps:

  1. Make sure that you have the following lines in your Apache configuration file httpd.conf and that they are uncommented:
    LoadModule dav_module modules/
    LoadModule dav_fs_module modules/
  2. Make sure that the following lines are present in your httpd.conf file:
    DAVLockDB /var/lib/dav/lockdb
    Alias /dav /var/www/html/davRepository
    <location /dav>
    Dav On
  3. Make sure that the permissions on the directory that you want to make available over WebDAV and the files inside it have suitable permissions, as Apache needs to access them.

Reload your Apache configuration by running /etc/init.d/httpd reload as root to make the configuration changes effective. Now you can add some files into the directory /var/www/html/davRepository and test the setup from a WebDAV client.

You should keep security considerations in mind when you set up a file share based on WebDAV. You can implement access restrictions using Apache's access control directives. You can also make these resources password-protected through authentication, using any of the mechanisms that Apache supports, such as Basic or Digest. You should never enable WebDAV functionality on Apache until you have access control in place.

WebDAV clients

Firefox has limited support for WebDAV. It can present the list of folders and files in the WebDAV folder, but you can only read files, and not make any modifications through the browser. You can view the directory listing using the URL http://hostname/dav/. This directory listing is similar to the regular directory listings generated by Apache.

If you want to upload new files to this folder or modify one of the existing folders, you can use a WebDAV-aware file browser like Nautilus and Konqueror. The URL for Nautilus is dav://hostname/dav. Once you've displayed the contents of this folder in the Nautilus window, you can simply drag and drop files from it to the local folders, or vice versa.

DavExplorer is a standalone DAV client written in Java. Unlike many other tools, it has support for WebDAV features such as editing metadata and versioning.

Cadaver is a command-line WebDAV client that ships with many Linux distributions. Its command syntax is similar to that of command-line FTP clients. You can launch cadaver by typing cadaver hostname/WebDAV share location -- for example, This puts you in a cadaver shell, much like an FTP shell, in which you can type commands like get, put, mget, and mput. Cadaver also has support for more WebDAV methods than file browsers like Nautilus, including methods like propset, propget, and propdel for managing the metadata related to the resource.


Even though you may have support at the file browser level available for WebDAV, without support at a lower level, many non-WebDAV-aware applications cannot use or manipulate these resources effectively. davfs2 is a Linux filesystem driver that lets you mount WebDAV folders into your filesystem. Once mounted, you can treat WebDAV resources as virtual local resources.

davfs2 uses neon, a WebDAV client library, with a C interface. Download neon and install it, if it is not already installed. Download the davfs2 source archive, unpack it, and run configure, make, and make install as root, and you are all set to mount WebDAV shares into your filesystem.

Once davfs2 is installed you can mount a share in the dav directory on the server at the mount point /mnt/dav on the localhost using the command mount -t davfs /mnt/dav.

davfs2 supports mounting even when the client is behind a proxy. It supports various authentication schemes, such as basic authentication and Kerberos. You can tweak davfs2 settings such as the location of client certificates, proxy settings, and various timeouts by editing the configuration file /usr/local/share/davfs2/davfs2.conf.


In the above example, the Apache configuration directive Dav on enables DAV functionality for the given location and sets up the default filesystem provider (driver) called mod_dav_fs as the back end to interface with the filesystem. The main responsibilities of the provider are to provide lock and metadata management and to interface with the filesystem on the server. mod_dav is modular, and it can work happily with providers other than the default mod_dav_fs. mod_dav_svn is one such driver that makes Subversion repositories available over WebDAV. You can download mod_dav_svn as an RPM file and install it. For a simple mod_dav_svn configuration, add these lines to Apache's configuration file:

DAVLockDB /var/lib/dav/lockdb
<location /dav>
Dav svn
SVNPath /var/www/davrepo1

For a detailed discussion on the use of Subversion with Apache, see Version Control with Subversion.

WebDAV is a great way to turn the Web into a writable medium. With tools that are available across platforms and support for versioning, you can use WebDAV as a replacement for other file sharing mechanisms, as it makes the process of collaboration easier and more productive.


  • Apache & Web Servers
Click Here!