taken from http://www.digital-arcanist.com/sanctum/article.php?story=20070427101250622
copied here for personal use
Friday, April 27 2007 @ 10:12 AM MDT
Contributed by: highmage
Views: 6,023
This HOWTO will show you how to create WebDAV enabled directories hosted on your Apache webserver. I wrote this using Ubuntu Server 7.04, but it should work on previous Ubuntu releases and (with only minor modifications) any other Linux distro.
- What is WebDAV?
- Install the Proper Software
- Add Modules
- Create LockDB file for WebDAV
- Setup Authentication and Add Users
- Create the WebDAV Directory
- Configure Apache
- Restart Apache and Test
WebDAV stands for Web-based Distributed Authoring and Versioning. It was designed to allow groups of individuals to edit and manage files stored on a web-server. The protocol allows the creation of “web-shares” which can be used for file storage, collaborative projects, editing websites themselves, and any number of other things. WebDAV supports features like editing, copying, and moving of files, file locks, resource lists, and file property modification. Most operating systems, including MS Windows, support WebDAV directories.
The first thing you will need (obviously) is a functioning apache2 webserver. If you happened to have install Ubuntu Server Edition with the LAMP option, then you’re set. Otherwise, you’ll need to get a few things with apt. Do this however you want; I will use the command line. While you’re at it, you might as well get PHP to go with it.
apt-get install apache2 php5 libapache2-mod-php5
Fortunately, Apache 2.x comes with mod_dav already installed, we just have to activate it. We can do this by making some symlinks.
cd /etc/apache2/mods-enabled
ln -s ../mods-available/dav* .
Next we need to set up a DAVLockDB file for WebDAV to use. This is a very important step, as you’ll wind up with Internal Server Errors if you try to use WebDAV without it.
mkdir /usr/share/apache2/var
touch /usr/share/apache2/var/DAVLock
chown -R www-data:www-data /usr/share/apache2/var
WebDAV can open your web server up to security risks. You don’t want just anyone to wander in and change your files! There are several ways you can do authentication for your WebDAV directory, but htpasswd is the easiest and probably best for most cases. We’ll make the passwords using MD5 and store them where we store the apache configurations and add an initial user while we’re at it.
htpasswd -m -c /etc/apache2/.htpasswd
You can use this command to add more users later or change their passwords. Just remember to remove the -c option or you’ll truncate your password db every time!
Okay, almost done. Let’s make a directory in our web document root where we will run our WebDAV. I’m calling it myWebDAV. This is the folder in which your authorized users will be able to add, delete, and modify files. The directory will need to be writable by the web server.
mkdir /var/www/myWebDAV
chown www-data:www-data /var/www/myWebDAV
Now all we need to tell Apache how to use WebDAV and where to enable it. This consists of adding a few definitions to the user-defined config file at /etc/apache2/httpd.conf. Open that file with an editor and add lines similar to those below.
## Location of the DavLock file
DavLockDB /usr/share/apache2/var/DavLock
## Set up the myWebDAV directory to use WebDAV and authentication
<Directory "/var/www/myWebDAV">
Dav On
AuthName "WebDAV Login"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
## Limit access for enhanced security
<LimitExcept GET HEAD OPTIONS POST>
require valid-user
</LimitExcept>
Order allow,deny
Allow from all
</Directory>
That’s it! Restart your web server and you’re good to go. You and your friends/coworkers/etc can now login and modify the files at http://your.domain.com/myWebDAV.
/etc/init.d/apache2 restart



