PiDav – WebDav Raspberry Pi Tutorial – Part Two

Raspberry Pi WebDav part 2
In part one of the WebDav Raspberry Pi tutorial you were shown how to set up your Pi with Apache.

Apache will act as your web serving part of the PiDav solution. Next up I will show you how to setup WebDav and configure a user so that you can securely connect and save files on you WebDav server.

I used this article as a basis for this post and I’d strongly recommend you have a look at it as there are some other elements you may want to do (especially if you plan to access from Windows).

Right so now we have Apache installed you need to enable the relevant module with the following command:

sudo a2enmod dav_fs

Next up we need to enable the module:

sudo a2enmod auth_digest

So now you need to create a virtual host directory /var/www/web1/web and then make www-data the owner of the directory you create:

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

Now edit the default Virtual Host file by running the following command:

sudo nano /etc/apache2/sites-available/default

Now copy the text from this file into your default site.

You will be prompted to create a password for this account. I suggest using your default pi password.

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

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

With that all done reload Apache:

sudo /etc/init.d/apache2 reload

Phew! Now all you need do is pick your favorite WebDav client and connect… Here I’m using the excellent Documents from Readdle on an iPad.
When connecting inside your next you need to type the URL as http://IP-ADDRESS/webdav20130124-181429.jpg

Your username is pi and password is what you just set.


Got all that? If you got stuck or it didn’t work feel free to get in touch and I will help you if I can.

  12 comments for “PiDav – WebDav Raspberry Pi Tutorial – Part Two

  1. Stilman
    30/01/2013 at 3:32 pm

    Wow that was a lot of work.

    I assume you did not know that BarracudaDrive was ported to the Raspberry Pi and is available via the Pi store.

    BarracudaDrive is much faster and uses a lot less RAM on the Raspberry Pi since BarracudaDrive is designed for resource constrained systems such as the Pi.

    Check out the BarracudaDrive WebDAV NAS tutorial, which continues where you left off.

    • 30/01/2013 at 4:34 pm

      Thanks, I wasn’t aware of the Barracuda Drive port, so will take a look.

  2. 08/03/2013 at 8:33 pm

    Hi mate, thx for the tutorial..seems there’s a step or two missing? When copying to the sites-avalable file, are we replacing the default contents or adding a new virtual host below.

    Also, you mentioned that a password prompt will appear – when is that supposed to happen? It doesn’t happen after saving the sites-enabled file in nano.

    I can’t connect properly to webdav because it seems that the user/pass isn’t registered. I can connect to the webserver however and see a blank directory listing at my http://LOCAL_IP_ADDRESS

    Also, are we supposed to copy the password.dav file from somewhere? It wasn’t created, so I’m getting a:
    chown: cannot access `/var/www/web1/passwd.dav’: No such file or directory

    any ideas?

    EDIT- My answers were solved by following the linked tutorial at the top of this post! Be sure to do that!

  3. Andreas B
    21/10/2013 at 12:11 pm

    Could you please tell me/us how to add a second folder/virtualhost?

  4. Heinz
    14/12/2013 at 10:41 am

    Works like a charm with http. What are the steps to work with https? Apache is running with ssl and for instance wordpress and phpmyadmin are accessible via https.

    • Augusto
      09/02/2014 at 11:38 am

      I was just going to comment on this too. But first, thanks Gary for making this tutorial!

      This solution is OK if you’re going to access the data from your own network, but it’s not secure if it’s over the internet as it uses plain HTTP… so anyone can capture your username, password or any files that you upload or download.

      To make it secure it needs to be over HTTPS. I think some of the steps to achieve that are described here:

  5. Al
    06/01/2018 at 5:06 pm

    Help please. 🙂

    Think I’ve followed all these instructions but no workie:

    $ cadaver http://localhost/webdav/
    Could not access /webdav/ (not WebDAV-enabled?):
    405 Method Not Allowed
    Connection to `localhost’ closed.
    dav:!> exit

    Newly created Pi3. updated as soon as i brought it uip and followed the instructions.

    pi@pi:/var/www $ ls -lrt
    total 8
    drwxr-xr-x 2 root root 4096 Jan 6 10:26 html
    drwxr-xr-x 3 root root 4096 Jan 6 10:32 web1
    pi@pi:/var/www $ cd web1
    pi@pi:/var/www/web1 $ ls -lrt
    total 8
    drwxr-xr-x 2 www-data root 4096 Jan 6 10:28 web
    -rw-r—– 1 root www-data 108 Jan 6 10:34 passwd.dav
    pi@pi:/var/www/web1 $

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.