Publishing iCal to Apache

The recently released iCal can publish calendars; either to your .mac account - or to any DAV enabled webserver. Apache 2.0 will work just fine out of the box; for apache 1.3 - from version 1.3.27 you are fine; earlier versions need a patch (see below) as apache was somewhat too strict in its Digest authentication parsing.

Source

Getting the source:

Note that on MacOSX (from 10.3.1 and beyond) you already have all of these installed in the right versions - and you just need to uncomment the mod_digest and mod_dav lines in your /etc/httpd/httpd.conf file. Use 'sudo to edit this file and then do sudo apachectl restart. Check your /var/log/httpd/* files before skipping over the next section and onto Configuration.

And if you are using apache 1.3 you may need to install mod_dav. Which can be downloaded at this site.

DAV and mod_perl and XML::Parser and expat and expat-lite

In the rare case you are using all of the above AND you are getting a segfault or other startup error due to a symbol clash.. then know that this is propably due to the expat-lite whcih is shipped with apache and which is compiled in by default clashing with the expat dependencies of mod_perl, python, php or XML::Parser.

In this case you can do two things:

  1. Recompile apache with RULE_EXPAT=system.
  2. Recompile apache with --disable-rule=EXPAT and make sure you specify --with-expat=/usr/local.. (or wherever) when you compile mod_dav.
Email me if the above is too cryptic and I'll spend some cycles making it cleaer.

Configure

Simply add the following for DAV activation:
LoadModule dav_module         /path/to/libexec/apache/libdav.so
AddModule mod_dav.c
DAVLockDB /var/db/DAVLock
DAVMinTimeout 600
Next - create the empty lock database file for DAV. These must be readable for the web user. Search in your httpd.conf for the directives User and Group to find as what userid apache is running:
#grep User httpd.conf
User www
#grep Group httpd.conf
User www
In the above example that is user id www and group www. So next create the empty lock databases and make sure that they are owned and writable by the web server:
touch /var/db/DAVLock.dir
touch /var/db/DAVLock.pag
chown www /var/db/DAVLock.*
chgrp www /var/db/DAVLock.*
chmod 640 /var/db/DAVLock.*
Next create a directory for your iCal; say 'ical' in your DocumentRoot and then add the following snippet to make it all work:
<Directory ...../htdocs/ical/>
	# Make sure people authenticate
	#
	AuthType Digest
        AuthName iCal
        AuthDigestFile "/usr/local/etc/apache/dav.digest.passwd"

	# except when doing normal things.
	#	
	<LimitExcept GET HEAD OPTIONS>
		require valid-user
	</LimitExcept>

	# The crux :-)
        DAV On

	#
        Order allow,deny
        Allow from All
	#
        Options All
</Directory>
This will allow -anyone- access to the calendar you publish -and only those with a valid username/password write access. Consult the documentation for more options.

You will have to make sure that the above directory exists; and is writable:

mkdir	....../htdocs/ical
chown www  ....../htdocs/ical  
chgrp www  ....../htdocs/ical  
Next create password file and add some accounts; the -c flag is only used once to create the file.
htdigest -c dav.digest.passwd iCal mary
htdigest dav.digest.passwd iCal peter
htdigest dav.digest.passwd iCal frank
Then restart apache and you are in bizness!
tail -f /some/path/logs/error_log &
apachectl restart
If there is any problem - keep checking the error_log ! Most problems are related to read or write permissions. Do not forget that though apache starts as root; it will run with significantly less permissions. See the User and Group directives. And these are the context in which the DAV module does its work (and read/writes to the directory and the lock files).

Using it

Fire up iCal, select a Calendar and go to 'Publish..' under 'Calendar'. Keep hitting the 'Publish on a web server' until an extra space appears where you can enter a URL, a login and a password. Enter something like http://www.yourside.com/ical/ (corresponding to the above Directory and you are done.

Feedback

Beer or complaints to dirkx(at)webweaving.org. Sofar thanks to Flinn Mueller, Alberto and Shawn Yeager in helping fixing the typos and pointing out ommissions. Keep them coming.













(c) 2002-2004 Dirk-Willem van Gulik, All Rights Reserved. This page and the information herein is under this license. Last modified: January 2003.