How to enable WebDAV on Apache

Enabling WebDAV in Apache

This applies to the LAMP appliance (and technically any other appliance that includes Apache2 web server - however you may need to do further tweaks). Note that this is not the only way, nor is it being suggested as the best, just one that was suggested as the easiest. It was taken from a post in the forums here by Steffen with a little tweaking and extra info added.

Create a folder for your webDAV content. I have put it in /root but it can go elsewhere:

mkdir /root/webdav
chown www-data:root /root/webdav

Enable the required modules:

a2enmod dav_fs
a2enmod dav

Create a new virtual host config:

nano /etc/apache2/sites-available/webdav

Then add something like this to you virtual host config (and save it):

Alias /webdav /root/webdav

<Location /webdav>
   DAV On
   SSLRequireSSL
   Options None
   AuthType Basic
   AuthName webdav
   AuthUserFile /root/passwd.dav

   <LimitExcept GET OPTIONS>
     Require valid-user
   </LimitExcept>

</Location>

Now restart Apache:

service apache2 restart

Configure your users and passwords:

htpasswd -c /root/passwd.dav user1

And input the desired password for 'user1'. Additional users can be added by repeating that line, however omit the '-c' switch as the password file already exists.

Set permissions for the password file:

chown www-data:root /root/passwd.dav
chmod 460 /root/passwd.dav

For users wishing to access WebDAV folders via Windows, an additional step may be required. Have a read here.