Standalone WebDav server using mod_dav

Posted by Yoshimasa Niwa on 02/01, 2009

As you know, iDisk on MobileMe is implemented as WebDav server. There are many implementations(with Ruby, Python or Java etc…) of WebDav server but any implementations isn’t good except mod_dav which is working on Apache web server.

mod_dav is good implementation but one thing I didn’t like is it works on Apache web server. These days I use nginx as a front end web server, SSL proxy and each services like this website you are reading are working as back end of it. I’d add webdav service to back end of nginx but normal mod_dav and documentation are written with the view of using it with Apache front end web server.

So, I made a tiny script to use mod_dav as standalone back end service.


How to use it?

At first, download it and extract somewhere on your web server or localhost(for testing). I describe here with MacOS X 10.5(Leopard) but it should work on any UNIX like servers.

% cd ~/Desktop
% tar xzvf standalone_webdav-*.tar.gz
% cd standalone_webdav

This script require to install Apache web server 2.2 or above with mod_dav module. Leopard has them so nothing needed to install on MacOS X. If you use Ubuntu, just install apache2 package.

% sudo aptitude install apache2

Then making password file to protect WebDav server. This script is using digest authentication with “dav” realm.

% htdigest -c .htdigest dav (username for webdav)
Adding password for test in realm dav.
New password: (enter password)
Re-type new password: (enter password again)

Next, making a symlink named “modules” to the apache2 modules directory. Where this directory is depends on your installation of apache2. On MacOS X, it locates /usr/libexec/apache2, and on Ubuntu, it locates /usr/lib/apache2/modules

% ln -s /usr/libexec/apache2 ./modules

You can see these files in standalone_webdav

% ls -al (the result are omitted)
drwxr-xr-x .
drwxr-xr-x ..
-rw-r--r-- .htdigest
-rwxr-xr-x httpd
-rw-r--r-- httpd.conf
lrwxr-xr-x modules -> /usr/libexec/apache2

OK, now you can boot up the httpd only for mod_dav

% ./httpd
Usage ./httpd [start|foreground|stop|restart]
% ./httpd start
Booting /usr/sbin/httpd...
/usr/sbin/httpd is running (pid=28147)

The default port number is 6000. you can change it by editing head of httpd.conf. Let’s check it from Open “Go” - “Connect to Server…” on the menu of, then put “http://localhost:6000” and click Connect.

Connect to the webdav server Logging into it

You’ll see the login dialog and put the user name and password which you put to htdigest. Authentication will be success and the disk will be mounted on your Desktop like iDisk or any other external drives.

After testing it, you can stop this WebDav server by next command.

% ./httpd stop
Killing 28147...
/usr/sbin/httpd was stoped

The documents which you upload to it are located in document_root directory which will be created by this script. Also, some log file are generated in log directory.



Your name
Your email
Your url
Your comment