How to install WebDAV with Lighttpd on Debian 8 (Jessie)

This guide explains how to set up WebDAV with Lighttpd on a Debian 8 (Jessie) server. WebDAV stands for Web-based Distributed Authoring and Versioning and is a set of extensions to the HTTP protocol that allows users to directly edit files on theLighttpdd server so that they do not need to be downloaded/uploaded via FTP. Of course, WebDAV can also be used to upload and download files.


1 Preliminary Note

I'm using a Debian 8 server with the IP address here. My setup is based on the Debian minimal server tutorial, but any Debian system that does not run a web server yet should be fine.


2 Installing WebDAV

You can install lighttpd (if it's not already installed), the lighttpd WebDAV module and the apache2-utils package (which contains the tool htpasswd which we will need later on to generate a password file for the WebDAV share) as follows:

apt-get -y install lighttpd lighttpd-mod-webdav apache2-utils

Afterwards, we must make sure that the directory /var/run/lighttpd is owned by the www-data user and group. This directory will contain an SQLite database needed by WebDAV:

chown www-data:www-data /var/run/lighttpd/

Next, we enable the modules mod_auth and mod_webdav:

lighty-enable-mod auth
lighty-enable-mod webdav

Reload Lighttpd afterwards:

service lighttpd force-reload


3 Creating a Virtual Host

I will now create a Lighttpd vhost ( in the directory /var/www/web1/web. If you already have a vhost for which you'd like to enable WebDAV, you must adjust this tutorial to your situation.

First, we create the directory /var/www/web1/web and make the lighttpd user (www-data) the owner of that directory:

mkdir -p /var/www/web1/web
chown www-data:www-data /var/www/web1/web

Then we open /etc/lighttpd/lighttpd.conf and add the following vhost to the end of the file:

nano /etc/lighttpd/lighttpd.conf
$HTTP["host"] == "" {
  server.document-root = "/var/www/web1/web"

Afterwards we restart lighttpd:

service lighttpd restart


4 Configure the Virtual Host for WebDAV

Now we create the WebDAV password file /var/www/web1/passwd.dav with the user test (the -c switch creates the file if it does not exist):

htpasswd -c /var/www/web1/passwd.dav test

You will be asked to type in a password for the user test.

(Please don't use the -c switch if /var/www/web1/passwd.dav is already existing because this will recreate the file from scratch, meaning you lose all users in that file!)

Now we change the permissions of the /var/www/web1/passwd.dav file so that only root and the members of the www-data group can access it:

chown root:www-data /var/www/web1/passwd.dav
chmod 640 /var/www/web1/passwd.dav

Now we modify our vhost in /etc/lighttpd/lighttpd.conf so that it looks as follows:

nano /etc/lighttpd/lighttpd.conf
$HTTP["host"] == "" {
  server.document-root = "/var/www/web1/web"
  alias.url = ( "/webdav" => "/var/www/web1/web" )
  $HTTP["url"] =~ "^/webdav($|/)" {
    webdav.activate = "enable" = "disable"
dir-listing.activate = "enable" webdav.sqlite-db-name = "/var/run/lighttpd/lighttpd.webdav_lock.db" auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/var/www/web1/passwd.dav" auth.require = ( "" => ( "method" => "basic", "realm" => "webdav", "require" => "valid-user" ) ) } }

The alias.url directive makes (together with $HTTP["url"] =~ "^/webdav($|/)") that when you call /webdav, WebDAV is invoked, but you can still access the whole document root of the vhost. All other URLs of that vhost are still "normal" HTTP.

Restart Lighttpd afterwards:

service lighttpd restart


5 Testing WebDAV

We will now install cadaver, a command-line WebDAV client:

apt-get -y install cadaver

To test if WebDAV works, type:


You should be prompted for the username. Type in test and then the password for the user test. If all goes well, you should be granted access which means WebDAV is working ok. Type quit to leave the WebDAV shell:

root@server1:/home/administrator# cadaver
Authentication required for webdav on server `':
Username: test
dav:/webdav/> quit
Connection to `' closed.

Share this page:

2 Comment(s)