Set up WebDAV-Server

First install apache2:

sudo aptitude install apache2 apache2-doc

Then enable the needed mods dav and dav_fs:

sudo a2enmod dav
sudo a2enmod dav_fs

and reload the apache2 configuration:

sudo /etc/init.d/apache2 reload

Now setup a directory for webdav access. You can do this by adding the following lines in the file /etc/apache2/sites-available/000-default:

Alias /webdav "/var/webdav/"
<Directory "/var/webdav/">
  DAV on
  Options +Indexes
  AuthType Basic
  AuthName DAV
  AuthUserFile /etc/apache2/passwords
  Require valid-user
  php_flag engine Off
  BrowserMatch "gvfs/*" redirect-carefully
  AllowOverride None

php_flag tells php not to execute files when accessing php files on the webdav share.

Create the file /etc/apache2/passwords and set up users with access rights:

sudo htpasswd -c /etc/apache2/passwords <username>
sudo chown root:www-data /etc/apache2/passwords
sudo chmod 640 /etc/apache2/passwords
sudo /etc/init.d/apache2 restart

You might want to also enable SSL on the apache webserver (otherwise Windows Clients can't connect):

More on the SSL stuff: