WebDAV Configuration With Apache2 On Debian Etch

Web-based Distributed Authoring and Versioning, or WebDAV, is a set of extensions to the Hypertext Transfer Protocol (HTTP) which allows users to collaboratively edit and manage files on remote World Wide Web servers. The group of developers responsible for these extensions was also known by the same name and was a working group of the Internet Engineering Task Force (IETF).

Install apache 2 and enable webdav in debian

Install apache2 using the following comamnd

#aptitude install apache2

Enable webdav modules using the following commands

#a2enmod dav_fs

#a2enmod dav

Restart Apache web server using the following command

#/etc/init.d/apache2 restart

Create Virtualhost in apache

Now you need to create a default apache vhost in the directory /var/www/webdav.Now you need to modify default apach cofiguration file located at /etc/apache2/sites-available/default

You need to create /var/www/webdav directory and make www-data use the owner of the directory.

#mkdir /var/www/webdav

#chown www-data:www-data /var/www/webdav

Now you need to make a backup of default apache server config file

cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default.back

Now you need to edit the /etc/apache2/sites-available/default file

#vi /etc/apache2/sites-available/default

add the following lines

NameVirtualHost *

<VirtualHost *>

ServerAdmin root@localhost
DocumentRoot /var/www/webdav/
<Directory /var/www/webdav/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Restart Apache web server using the following command

#/etc/init.d/apache2 restart

Configure The Virtual Host For WebDAV

If you don’t want to use password authentication you don’t have to use the htpasswd steps this is very useful when you are using ip phone configuration for backup.
Now we create the WebDAV password file /var/www/webdav/passwd.dav with the user test (the -c switch creates the file if it does not exist)

#htpasswd -c /var/www/webdav/passwd.dav admin

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

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

#chown root:www-data /var/www/webdav/passwd.dav

#chmod 640 /var/www/webdav/passwd.dav

Now we modify our vhost in /etc/apache2/sites-available/default and add the following lines to it

#vi /etc/apache2/sites-available/default

add the following lines to

Alias /share /var/www/webdav

<Location /share>
DAV On
AuthType Basic
AuthName “webdav”
AuthUserFile /var/www/webdav/passwd.dav
Require valid-user
</Location>

Restart Apache web server using the following command

#/etc/init.d/apache2 restart

Test your Configuration

First you need to install cadaver, a command-line WebDAV client using the following command

#apt-get install cadaver

To test if WebDAV works, type the following comamnd from the terminal

cadaver http://localhost/share/

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

# cadaver http://localhost/share/
Authentication required for admin on server `localhost’:
Username: admin
Password:
dav:/share/> quit
Connection to `localhost’ closed.

Sponsored Link

7 thoughts on “WebDAV Configuration With Apache2 On Debian Etch

  1. Has anyone had success getting this to work with Microsoft Expression Web? Although my setup seems to work with cadaver and even with XP Web folders, Frontpage and Expression Web choke. Mostly I end up with “301 Document Moved” errors.

  2. These instructions leave some significant security holes. In particular, you probably do not want the password file in the same directory tree that the web server will be providing to the world.

  3. Excellent tip, I work with a team of individuals who I need to setup a file share for and I was prepared to attempt SMB over a tunnel. This is a much better solution and that it utilizes Apache means it is something I already understand.

    As for Jeff’s comment about plugging into Microsoft software… well, I just don’t have a clue – why you would want to do this I do not know, but I suspect it has something to do with the infamous “pointy haired boss”.

  4. I don?t usually reply to posts but I will in this case. I?ve been experiencing this very same problem with a new WordPress installation of mine. I?ve spent weeks calibrating and getting it ready when all of a sudden? I cannot delete any content. It?s a workaround that, although isn?t perfect, does the trick so thanks! I really hope this problem gets solved properly asap.

  5. I built this verbatim, however I get this error apparently because there’s no … everything points to /var/www/webdav which does include password file. Here’s the error from cadaver:

    dav:/share/> mput /home/timothy/debian.png > webdav
    Uploading /home/timothy/debian.png to `/home/timothy/debian.png’:
    Progress: [=============================>] 100.0% of 681248 bytes failed:
    405 Method Not Allowed
    Uploading > to `/share/%3e’: Could not open file: No such file or directory
    Uploading webdav to `/share/webdav’: Could not open file: No such file or directory

Leave a comment

Your email address will not be published. Required fields are marked *