stiefels.net Just another WordPress weblog

30Nov/082

Synchronizing OmniFocus via WebDAV on Gentoo Linux

The biggest new feature in [OmniFocus](http://www.omnigroup.com/applications/omnifocus) 1.5 will be the possibility to synchronize multiple OmniFocus to one single database.
This is very nice as, I suppose, a lot of people have multiple installations of OmniFocus and keeping all of them up to date is a hassle. Especially now, as OmniFocus is also available for the iPhone a synchronization feature is an absolute must to keep doing GTD "stress-free".

There are several ways to set up the synchronization feature:
* **[MobileMe](http://me.com)** This is probably the most convenient way but it requires you to have a MobileMe account.
* **Bonjour** Synchronizing via Bonjour requires to make one Mac to function as a "database server" (which has to be up and running if you want to sync) and synchronizing is only possible over the local network.
* **Disk** If you have NAS system or a USB hard drive connected to your AirPort you could use this option. But unfortunately the iPhone does not support this way.
* **WebDAV** If you have access to a web server you could use that one as an OmniFocus database server. This way you have access to your tasks from all over the world.

In this tutorial I want to show you how you can configure an apache web server to support WebDAV and what you have to do to make OmniFocus use your very own "cloud".

I'll use Gentoo Linux to explain the single steps but it should be similar on different platforms. There is also a tutorial on how to configure [Leopard to speak WebDAV](http://manas.tungare.name/blog/howto-setup-webdav-on-mac-os-x-leopard-for-syncing-omnifocus-to-iphone/).

## What is WebDAV?
The first question may be: What the heck is WebDAV?

Most parts of the web is read-only, right? You can't go to apple.com and change their front page by putting some Dell products on it. The standard HTTP protocol doesn't allow such operations.
But what if you want to *allow* other people to change your data (without using content management systems)?
To extend the standard HTTP functionality a working group of the [Internet Engineering Task Force](http://www.ietf.org/) developed a protocol called WebDAV which means *Web-based Distributed Authoring and Versioning*. This extension to HTTP allows a web page to become both a readable and writable medium.

OmniFocus is using this protocol not to modify a web page but to keep your "task database" up to date.

## Convincing the apache web server to speak WebDAV
The first thing we have to do is to make apache speak WebDAV.

Support for WebDAV can be added to apache by loading two modules:
* [mod\_dav](http://httpd.apache.org/docs/2.0/mod/mod_dav.html): Enables WebDAV functionality
* [mod\_dav\_fs](http://httpd.apache.org/docs/2.0/mod/mod_dav_fs.html): Provides access to resources on the server's filesystem

### Check WebDAV modules

To see if you've already compiled these two modules, you can have a look in */usr/lib64/apache2/modules* (or */usr/lib/apache2/modules* if you have a 32-bit system). There should be a *mod_dav.so* and a *mod_dav_fs.so* file.

### Compile WebDAV modules
If you can't find your WebDAV modules you'll have to compile them.
To do this, edit your */etc/make.conf* file and add *dav* and *dav_fs* to the *APACHE2_MODULES* variable.

APACHE2_MODULES="dav dav_fs [...]"

If you do an

emerge -vp apache

you should see that the *dav* and *dav_fs* modules will be compiled the next time you compile apache.
To compile apache, simply type

emerge apache

This may take some time but once it is finished you should see the compiled modules in your apache modules directory.

### Activating the WebDAV modules
To activate your WebDAV modules you have to edit your */etc/conf.d/apache* file and change the *APACHE2_OPTS* variable by appending *-D DAV*.

APACHE2_OPTS="-D DAV [...]"

## Enabling WebDAV for Virtual Host
Assuming that you've already set up a virtual host for your webpage, we only have to modify this virtual host configuration.
All we need is to define a directory within your DocumentRoot which should be used for OmniFocus and enable WebDAV for it. Also, we want to set up a password protection so nobody else has access to your data. Enabling SSL for this domain is probably not the baddest idea but that is not topic of this tutorial.


DAV On
AuthType Basic
AuthName "OmniFocusLogin"
AuthUserFile /var/www/sub.domain.com/omnifocuslogins
Require valid-user

This defines that your OmniFocus database is reachable at *http://your.domain.com/omnifocus*.

Don't forget to create the *omnifocus* directory in your *htdocs* directory and change the owner to *apache*:

mkdir /var/www/your.domain.com/htdocs/omnifocus
chown -R apache:apache /var/www/your.domain.com/htdocs/omnifocus

## Password protection
As you can see we already configured password protection for this URL.
All we need to do is to create the *omnifocuslogins* file in which we will define the username and passwords.
To create this file you can simply run this command:

htpasswd2 -c /var/www/sub.domain.com/omnifocuslogins myuser

## Restart Apache
To make all your changes active you have to restart apache.

/etc/init.d/apache2 restart

Apache now allows read and write access to the */omnifocus* directory via WebDAV.

## Configuring OmniFocus
Telling OmniFocus to use your newly configured WebDAV server for synchronization is very easy.
All you have to do is to open the application's preferences, select the *sync* tab, select *Sync with: Advanced* and enter the URL of your server. By clicking on *sync now* you start the synchronization process.

OmniFocusSyncPrefs.png

The first time you are doing this you have to enter the username and password you have defined above.
If everything worked fine you should see something like *LastSync: Today, 3:26pm". Congratulations!

Comments (2) Trackbacks (1)
  1. Hi Simon! Awesome tutorial! I have never heard about WebDAV before but it sounds really cool! :)
    See you soon!

  2. Thanks Simon! Just finished installing & configuring and it worked perfectly. Great work!

    Cheers,
    Tom


Leave a comment