WebDAV and Apache
There are plenty of reasons why you would want to setup an online storage solution. Whether you need to have your files accessible from anywhere, or want to share them with your friends, or to distribute your software, you will need to evaluate the many different technologies available and find the one that fits your needs and requirements.

You probably already thought about NFS, FTP, maybe SSH or even Subversion to access files in a particular directory. They all have their own set of features, advantages and particularities.

There is another one that may be worth considering: Using WebDAV over Apache.

Here are few key points that I find interesting:

  • It is easy to set up.
  • If you already have Apache running on your server, you don’t need to run another daemon (unlike NFS or FTP).
  • You have access to an impressive number of Apache configuration directives, which allows you to finely control who has access to your files, from where, and under which mode (read, write). You have also access to all other Apache features, like LDAP authentication, SSL encryption and custom log capabilities.
  • Your files can be accessible through a web browser, and on a Linux compatible system you can also mount the WebDAV share locally, giving you direct and easy access to your files (using the davfs filesystem), so you don’t have to use a client (unlike FTP). There are also several clients available for Windows and Mac OS.

Curious? Read on, and you should be able to get started quickly.

I am leaving distro-specific and technical details out on purpose, it would be useless to rewrite the excellent documentation you should be able to find online.
I tested this on a Apache server installed through yum on a CentOS 5 server, and I used an Ubuntu 7.04 client to mount the directory locally (I had to install the davfs package with apt-get).

Set up a simple WebDAV share

The Apache server I got through yum came with the mod_dav and mod_dav_fs modules already installed. Easy!

You will have to make sure that the following configuration lines are present in your Apache configuration file:
DAVLockDB /var/lib/dav/lockdb
DAVDepthInfinity On
DAVMinTimeout 600

Then you will need a <Directory /path/to/webdav/share>...</Directory> section. It should contain all the usual directives (Options ..., Deny from..., Allow from ...), and this one:
DAV on

Example:
<Directory /var/www/html/webdav_shared_dir>
DAV on
AllowOverride All
Options Indexes
Order deny,allow
Allow from all
</Directory>

Finally you should make sure that whatever user Apache is running under (typically apache, www-data, www, or nobody) has write access to that directory.

That’s it! I told you it was simple.

Now you can mount the WebDAV shared directory on your local box:
mount -t davfs http://webdav.spry.com/shared_dir /mnt/webdav_shared_dir
This allows you to add/delete files, and read/write the existing ones.

Now you can start working as if the shared directory was part of your local filesystem.

Once you have put some files on it, just point your browser to http://webdav.example.com/shared_dir, and your files should be accessible for reading.

Congratulations! You just set up a WebDAV shared directory, accessible from anywhere.

Use Apache’s directives to add more features

  • You need to restrict access to your files? Use Apache’s authentication capabilities, like LDAP or .htpasswords.
  • You need to have read/write access for yourself and read access for everyone else? Use require user ….
  • You need to encrypt communications to protect your data and password? Set up the WebDAV share in a virtualhost and add a SSL certificate.
  • You don’t want the WebDAV logs to be included in the main apache logs? Just use the appropriate log directives so it goes to a different file.

You can use any Apache configuration directive to customize your shared directory.

Digg It! del.icio.us Bookmarks Stumble It! Google Bookmarks