This page has moved to a permanent new location. The Home Page of Vikram Aggarwal is now available at www.eggwall.com. Please update your bookmarks, if you need to.























































Vikram Aggarwal

Setting up Mod_DAV for Linux

On Friday, March 4, I spent more than two hours setting up mod_dav with Apache on a webserver that I'm allowed to play with. Considering that this is quite an investment in time, I thought I should put up a HOWTO on how this setting up business is done. Feel free to mail me questions and I will add them to this list. I am not the definitive source for webdav information. However, I list a set of steps that you might wish to follow for some sanity in the process.

Why?

WebDAV is pretty cool. You can publish your Bookmarks, and calendars, and what have you online, so that others can read them. Very cool, isn't it? Macintoshes and Linux machines can access the partitions as a disk, and can read an write to them. A very cool technology. My primary motive was to be able to have a calendar in which the UCSB CS colloquia could be listed easily.

What you need?

For a start, you need a machine on which you have root, and which is connected to the Internet. This is an absolute requirement, as I'm sure you understand. You also need a good knowledge of UNIX in general, filesystems, users, groups, and all that jazz.

Your friends

Like I said, I had a lot of help setting this up from sites on the Internet. I could not have set this up without their help. So read the following links very carefully before setting out to do this. It will save you a lot of time in the long run.

Apart from that the following give you a lot of information about what is going on:

Begin

Setting up webdav is easy if you're just a little patient. Get yourself a good cup of tea, coffee, or your beverage of choice, and get some sleep. A refreshed mind is significantly sharper.

Read all the documents above. Know where your apache configuration files and logs are. Make sure that apache is running, and you know the version number. If you don't have Apache running, set it up right now.

Checkpoint

Verify that you can serve a page with Apache. You should be able to go to http://your.server.name/ and see something up there. If this doesn't work, go back and try to fix Apache's setup first.

Obtaining Webdav

Get webdav from the Mod_dav page listed above. Debian users might want to do an apt-get install. Whatever works on your system. Some compilations might be involved. I had Debian and so I didn't bother with recompiling the sources. mod_dav might add sections to your [HC]. If it didn't, then you need a section like this below:

<IfModule mod_dav.c>
    DAVLockDB   /var/lock/DAV/DAVLock
</IfModule>

This achieves the following. It tells that if mod_dav, the module is present, then its lock DataBase is in the given location. You get to tell Apache that mod_dav is around by the following lines inside your [HC] file. There should be lines of the "Loadmodule" nature already in there, and order might be important, so stick these after all the Loadmodules are over.

Loadmodule dav_module /usr/lib/apache/1.3/libdav.so
Addmodule mod_dav.c

Now restart Apache. You should know how to do this.

Checkpoint

Now, to verify that dav is being loaded, put some junk inside the IfModule mod_dav.c line, like this.

<IfModule mod_dav.c>
    DAVLockDB   /var/lock/DAV/DAVLock

    Oh how I adore thee, my warm lover!
</IfModule>

Apache does not like poetry much, and neither does mod_dav, and if it is being loaded, then apache will complain about this most rude intrusion into the config file. If that happens, the module is being loaded right, and things are great. Remove our lovely poetry and send it to your sweetheart. If there is no complaint, then it is because mod_dav is not being loaded. That's a bad thing. Did you add the Addmoudule lines well? If all else fails, look in the [AL] and [EL] logs to find out what is going on.

Permissions!

Debian ships with wrong permissions on some directories, and it is infuriating. So find out what user apache runs with (sometimes it is www-data and sometimes it is nobody, and sometimes it is apache). Also, note the group. This is sometimes (nogroup, or apache, or www-data). This is given in the [HC] file, you'll have to look for the lines of the following nature:

User nobody
Group nogroup

Good, now set the lock directory to be owned by this user and group with the 'chown' command. You know how to use it, right? Thought you might. Great. Now touch the lock file /var/lock/DAV/DAVLock, with

touch  /var/lock/DAV/DAVLock
chown nobody.nogroup /var/lock/DAV/DAVLock

Sometimes the existence of this file is shakey, and you are just making things easier for yourself.

Making the directories

Now make the directory that you will share with mod_dav. May I suggest /var/www/calendar? Of course, it could be absolutely anything you wish. Make it owned by the same user and group as apache. Then add it to your IfModule section (where you added the poetry) like so...

<IfModule mod_dav.c>
    DAVLockDB   /var/lock/DAV/DAVLock
        <Directory /var/www/calendar>
        DAV On
        <Limit PUT POST DELETE PROPFIND PROPPATCH MKCol COPY MOVE LOCK UNLOCK>
                AuthName "WebDAV access, you fool"
                AuthType basic
                AuthUserFile /etc/apache/htpasswd
                require user linus
        </Limit>
        </Directory>
</IfModule>

This is great, except that you should replace linus by your name, and then make a password for yourself with the htpasswd command. You know how to use it? Ok, I'll show you this one time...

htpasswd /etc/apache/htpasswd linus

If you don't have a file, then you should use the -c option, to create the file for you. Like this...

htpasswd -c /etc/apache/htpasswd linus

Again, change the to match the change in [HC]. This should create the /etc/apache/htpasswd file, if it didn't already exist. You can read the file, and see the username, and the encrypted password.

Checkpoint

Put a file that is owned by the apache user and the apache group inside that directory. Use your webdav client (Mac OS can do this in Finder -> Go -> Connect to Server). I haven't used too many clients, so I can't help you here. Depends a lot on your client configuration. This can happen from anywhere in the world, and anyone can read this stuff. Beware. You have been warned.

You can see the file? Great!

Final publishing!

Now get Mozilla calendar for Firefox. And you can see calendars of other people that have been published, and you can use the linus username to publish your changes as well.

If anything goes wrong, then check [AL] and [EL] files. They have a lot of descriptive complaints about what went wrong. File permissions are sometimes the biggest cause of headaches, as they were with me.


This page was made by a jubiliant juggler. You can reach me at "vikram-web at mayin dot org". Last updated at: Sat Mar 5 16:03:08 PST 2005