Back to the Tips Index
How to set up iCal to publish on your Leopard Mac:
All work done in Terminal.

% is the shell prompt -- don't type it in!

1) % cd /etc/apache2
   % sudo cp httpd.conf httpd.predav.conf
   % sudo vi httpd.conf
    Add this line below the definition of DocumentRoot:
	DAVLockDB /Library/WebServer/davlocks/DAVLockDB

    Add the following in the "Apple specific filesystem protection" area,
    underneath  the <DirectoryMatch>...</DirectoryMatch> block:

	# WebDAV folder
	<Directory "/Library/WebServer/Documents/dav">
	  DAV On
	  AuthName 'WebDAV'
	  AuthType Basic
	  AuthUserFile /etc/apache2/.htpasswd
	  AuthGroupFile /dev/null
	  <LimitExcept GET HEAD OPTIONS>
	    require valid-user
	  </LimitExcept>
	</Directory>

2) Think of a username you want to use for access to your iCal.  Anyone who
   will subscribe to your calendar will need to know this username and its
   associated password.  So, it is best not to make it *your* login name and
   password.  Maybe a name like 'dav' (no quotes) and a password that is
   memorable.
   % ls -la .htpasswd
   If the file exists do this:
        % sudo /usr/sbin/htpasswd .htpasswd username
   If the file did not exist, do this:
        % sudo /usr/sbin/htpasswd -c .htpasswd username

   In either case it will prompt for a password.  Enter one you can remember.

3) % cd /Library/WebServer
   % sudo mkdir davlocks
   % cd Documents
   % sudo mkdir dav
   % sudo mkdir dav/iCal

4) Check that the files are writable by the _www group:
   % cd /Library/WebServer
   % ls -l
      drwxrwxr-x  45 root  _www   1530 Nov 15 18:49 Documents
      drwxrwxr-x   4 root  _www    136 Nov 16 12:47 davlocks

   If the group is something else for Documents, do this:
   % sudo chgrp -R www Documents

   If the group is something else for davlocks, do this:
   % sudo chgrp www davlocks

   After setting the correct group, then check that both are group writable:
   % ls -l
      drwxrwxr-x  45 root  _www   1530 Nov 15 18:49 Documents
           ^
      drwxrwxr-x   4 root  _www    136 Nov 16 12:47 davlocks
           ^

   If you do not see a 'w' in the position marked by the circumflex (^) above,
   do this:

   % sudo chmod -R g+w Documents/dav
   % sudo chmod g+w davlocks

   Verify that the group is _www and that the directories are writable by group
   by doing another 'ls -l' command and seeing that there is now a w in the
   second "rwx" grouping.

5) Check the syntax of the httpd.conf file
   % apachectl -t
   It should report "Syntax OK"

6) Tail the server error log:
   % sudo tail -f /var/log/apache2/error_log
   Now type Apple-K to clear the terminal window so you are not confused by
   previously existing error messages in the error_log.  You will then only
   see new messages printed.  If the file does not exist, then you have never
   enabled web sharing.  If that is the case, then perform this step (6) after
   you have performed step 7.

7) Restart the web server by going to System Preferences, click "Sharing".
   Uncheck "Web Sharing" (if it is checked) and it should stop the web server.
   If you did uncheck it, and you are tailing the error_log from step 6,
   you'll see a message like this:
       [Thu Nov 15 20:42:33 2007] [notice] caught SIGTERM, shutting down


   Click the checkbox for "Web Sharing" and it should start up the web server.
   Check that the server starts up OK.  It should end in something like this:
   [Fri Nov 16 12:42:53 2007] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6
        OpenSSL/0.9.7l DAV/2 PHP/5.2.4 configured -- resuming normal operations

   If you have an error in your httpd.conf file, it may prevent your web server
   from starting up.  You made a copy of the original, you can compare the two
   and if necessary, copy the predav version back to httpd.conf and try again.

8) Publish your iCal calendar
   Start iCal
   Select a calendar by clicking on it on the left.
   Right click and select "Publish" or choose "Publish" from the Calendar menu.
   A dialogue will pop up.
   Select "a Private Server" for "Publish on"
   Enter "http://localhost/dav/iCal" for the "Base URL"
   Enter the user name you specified in step 2 above for the "Login"
   Enter the password you specified in step 2 above for the "Password"
   Click the "Publish changes automatically" checkbox
   Click "Publish" and watch the error log you are tailing from step 6 above
   If you see an error like this:
       [Fri Nov 16 12:43:07 2007] [error] [client ::1]
            Could not open the lock database.  [500, #400]
       [Fri Nov 16 12:43:07 2007] [error] [client ::1]
            (13)Permission denied: Could not open property database.  [500, #1]
   It means your web server process (httpd) does not have write access to the
   davlocks directory you created in step 3.  Verify that the directory exists
   and that it is writable by group www (review step 4).
           
   If you see an error like this:  
       [Fri Nov 16 12:31:32 2007] [error] [client ::1]
        (2)No such file or directory: Could not open password file:
        /etc/apache2/.htpasswd
   
   Then either the file doesn't exist or isn't readable.  The file was created
   by /usr/sbin/htpasswd in step 2 above.  Make sure the file is there:
        % cd /etc/apache2
        % ls -la .htpasswd
            -rw-r--r--   1 root  wheel     18 Nov 16 12:42 .htpasswd
                   ^
        If you do not see a third 'r' there (where the circumflex is located)
        you may need to do this:
                % sudo chmod o+r .htpasswd
   
   If the publish operation worked there should be no new messages at all
   printed to the error_log. 
All content copyright Howard Cohen 2007 , all rights reserved worlwide.
hoco(at)timefold(dot)com