To administer your WestHost account, please enter your
Domain Name or Server Manager Username.

Shared Calendars with Google and/or CalDAV

Many people have asked me how best to share a calendar between colleagues, between friends, husband and wife, offices in different locations, and some other cases where coordinating schedules is useful.

One solution that many are turning to is Google Calendar, which is a fantastic solution. It offers many features, including the ability to subscribe to your calendars from desktop applications. If your software supports iCal, you can subscribe to your Google Calendar by clicking on the calendar under My Calendars, and choosing Settings. In the window that appears, make sure that the Calendar Details tab is selected. At the bottom, you will see several buttons, one of which displays “ical” – there is a button for both “public” and “private”, which will show only your public events or all events (both public and private). Copy and paste the URL from this button into your calendar application.

The disadvantage of iCal is that it is one-way – you can subscribe to updates from Google Calendar from your desktop calendar (Mozilla Sunbird, Mozilla Lightning, or Apple iCal, for some examples), but you cannot edit them remotely.

To solve this, Google has recently allowed CalDAV access. To use it, you will make use of an URL like https://www.google.com/calendar/dav/your@gmail.address/events – where your@gmail.address is your Gmail address. Using this link from WebCal-enabled applications like Mozilla Sunbird or Mozilla Lightning, you can both view and edit calendars shared via Google Calendar.

For many, this solution alone is excellent. A web-based viewer and editor (http://www.google.com/calendar) is available, as well as having the freedom to integrate it with local desktop calendars which may have other events that are not public.

One example of how you may wish to use this is to have your departmental calendar on Google Calendar, and then have personal events in your own local, non-shared calendar. This becomes very useful for coordinating a team while still having freedom to record your own calendar events.

The astute reader will have noticed a few possible downsides to the above solution. Firstly, each calendar must have a unique Gmail address associated with it, which could become a problem if you have a lot of calendars. Secondly, the calendar data is stored at Google. If you are concerned about security, backups, or just control, this can be an issue. Because I’m a particularly paranoid sort, I would like to keep my calendar data where I can see it and back it up as frequently as I would like.

To this end, we’ll turn to WebDAV on your WestHost account. We will set up basically the same thing as we accomplished with Google Calendar with respect to the ability to subscribe to a calendar in Mozilla Sunbird, Mozilla Lightning, or any other iCal or CalDAV compliant application. Remember that iCal is one-way, while CalDAV is multidirectional. You may also hear the terms WebCal and iCal through WebDAV – these are different names for the same thing, the read and write-capable calendar we’re calling CalDAV.

By rolling our own solution, we will gain direct access to the underlying calendar files for security or backup, and we’ll gain the ability to have as many calendars as we want without relying on the “one calendar per gmail address” approach. It also looks a bit more professional having the calendar at your own internet domain name; but the downside is that we’ll lose the very nice and convenient Google Calendar interface.

To begin, we will edit the file /etc/httpd/conf/httpd.conf. You may access this file using an FTP client, or by logging into your File Manager at http://www.yourdomain.com/fm/. Using the file manager, you can click the first slash above the file listing, and then click etc, and then httpd, then conf, and finally click the edit icon next to httpd.conf.

At the end of the file, you will add a section like:

<Directory /var/www/html/dav>
DAV on
</Directory>

You may change /var/www/html/dav to anything else you would like, so long as it’s not already in use by web content. For instance, you may prefer /var/www/html/calendars. Once you have selected the location that you would like, create the directory – using File Manager, you can browse to /var/www/html/ and use the Create Directory button to make the location where your calendar data will be stored.

Advanced users may also add basic password protection here. To do so, use something like this instead:

<Directory /var/www/html/dav>
DAV on


AuthType Basic
AuthName "WebDAV Storage"
require valid-user
AuthUserFile /etc/davpasswd
</Directory>

Save the contents of httpd.conf.

You must then create the password file /etc/davpasswd. This may be done in File Manager, or you may upload it via FTP. You will place one user-password combination per line – to generate the encrypted passwords, use this convenient tool: http://home.flash.net/cgi-bin/pw.pl

Just enter the username and password there, and copy and paste the line it generates into the file you will upload or save to /etc/davpasswd.

Next, you must restart the web server in your account. This may be done by logging into Site Manager at http://www.yourdomain.com/manager/ and using the “Restart” link, or advanced users may accomplish it via SSH with the command “/etc/init.d/httpd restart”. Note that if you have an error in the httpd.conf file, your web site will not be available – in this case, check over what you entered in the file to make sure it appears correct.

You have now accomplished everything you need to do in order to store calendars. The next step is to create some!

Your desktop calendar application can create a calendar by just providing the URL http://www.yourdomain.com/dav/mycalendar.ics, where www.yourdomain.com is your domain name and /dav/ is the location you chose to store your calendars, and of course mycalendar.ics is the name of the calendar you would like to create.

We’ll proceed with Mozilla Sunbird as an example. It is a free download located at http://www.mozilla.org/projects/calendar/sunbird/ and works very well. Mozilla also produces a version integrated with Mozilla Thunderbird 2.x, called Lightning. In the upcoming Thunderbird 3 release, Lightning will be built in.

Start up Sunbird. From the File menu, choose New Calendar. Next, choose “On the Network”, and in the “Location” box type in the URL to your new calendar, e.g. http://www.yourdomain.com/dav/mycalendar.ics. Note that mycalendar.ics does not currently exist – Sunbird will create it on your server automatically when you add the calendar. Leave the Format option set at iCalendar (ICS) – because you are accessing a DAV-enabled location, Sunbird will automatically connect it in read/write mode.

Click Next, and you can choose a display name and color for events from this calendar. Finally, click Finish. If you had set up password protection, you will be asked for your username and password before the calendar can be saved.

You can now create as many calendars as you would like, knowing that they’re stored safely in your WestHost account where they are backed up and secure. Each calendar you create is stored on the server as an iCal format file, which you can download for backup purposes and use directly in most calendar applications if ever needed.

This entry was posted in General, Technical Support and tagged , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

5 Comments

  1. mark
    Posted February 18, 2009 at 11:14 pm | Permalink

    strange — i have followed your instructions precisely, and double-checked everything multiple times, but i am not successful publishing the calendar, no matter how hard i try.

    using sunbird, i get the following error:
    “Error getting calendar – Publishing the calendar file failed. status code: 500: Internal Server Error”

    and iCal says:
    “Publish failed for calendar ‘xx’ – Request to the server http://me@www.mydomain.com/dav/calendar.ics failed.”
    if i put in the wrong password, i get the same in sunbird:
    “Error getting calendar – Publishing the calendar file failed. status code: 500: Internal Server Error”

    but in safari, i get this instead:
    “Publish failed for calendar ‘xx’ – Authentication with server failed (http://me@www.mydomain.com/dav/calendar.ics).
    Please check your login and password information.”

    any ideas?

    thanks in advance,
    -mark

  2. Posted February 19, 2009 at 8:28 am | Permalink

    Hi Mark,

    “Internal Server Error” is not one of the most helpful error messages out there; it’s not really intended to be, actually, for some historical reasons. If you can take a look at your error log file (/var/log/httpd/error_log) it may have some clues as to what’s wrong. A few other things to check would be making sure the place you’ve got set to save calendars (/var/www/html/dav in this case) exists, and making sure that you restarted the account or Apache after making changes to httpd.conf.

    I would be happy to take a look at your account and find the problem if you’d like to send more details (and your domain name) to me at cmichaelis@westhost.com.

    Good luck!
    –Chris

  3. Posted June 1, 2009 at 10:14 am | Permalink

    Hi there,

    I’ve had a few questions about getting ’500 Internal Server Error’ when following these instructions. When using a DAV server, it needs a “lock database” – which keeps track of who is writing to a file to prevent collisions and similar information. This is usually created automatically.

    Sometimes you may see a line in httpd.conf that mentions DAVLockDB, like this:
    DAVLockDB /var/lib/dav/lockdb

    If the directory “/var/lib/dav” does not exist, it will cause a 500 internal server error. This is the most frequent cause of this error I’ve seen. To correct it, just create the directory “/var/lib/dav”, or change that line in httpd.conf to point to a location that exists.

    Good luck!
    –Chris

  4. Posted August 13, 2009 at 5:46 pm | Permalink

    I followed all of the instructions–I set up the directory as var/www/html/calendars. Double-checked my httpd.conf file to make sure it was correct, and made sure I had the davpasswd file correct.

    Sunbird give me an error message when I attempt to publish the calendar (error 403: Forbidden). It did not ask me for a password.

    I’m also trying to do it through Outlook 2007 (Outlook actually offers us more flexibility)–Outlook asks me for a login and password, but doesn’t accept any of the 4 passwords I enter.

    What am I missing?

    Thanks,
    Chris

  5. Posted August 14, 2009 at 8:39 am | Permalink

    Hi Chris,

    I took a look at your account, and the problem was just a missing /var/lib/dav/ directory. I created that, and checked over your configuration to be safe – looks good now. Go ahead and give it a try again. If you run into any other trouble, feel free to send a note to me at cmichaelis@westhost.com and I can take another look.

    Thanks!
    –Chris

Copyright © 1998–2014, WestHost. All rights reserved.  |  WestHost / Believe in Better Hosting. Privacy Policy