Use WebDAV to share files with all platforms

Nov 14, '02 09:34:33AM

Contributed by: benoitc

WebDAV stands for "Web-based Distributed Authoring and Versioning." It enables you to edit and manage files on a Web server remotely and in collaboration with others. You can read more about it at MacOS X supports WebDAV as a flavor of shared volume that you can mount through the Finder's Go -> Connect To menu command. Microsoft Windows also supports it as web folders. If you're using Windows XP, open My Computer, then choose Map Network Drive from the Tools menu.

We will use mod_dav with mod_encoding on apache to enable it on your mac OS X client.
Now it's time to open your Terminal.

[Editor's note: I have not tested this hint myself, and if it fails, it's possible you'll wind up with a non-functional Apache, so proceed at your own discretion. We ran a hint on setting up WebDAV a while back, but this one is much more thorough...]

1) Install mod_dav (
Type the following in the Terminal:

 % curl -O
% tar xvzf mod_dav-1.0.3-1.3.6.tar.gz
% pushd mod_dav-1.0.3-1.3.6/
% ./configure --with-apxs=/usr/sbin/apxs
% make
% sudo make install
% popd
2) Install libconv (
Type the following into the Terminal:
 % curl -O
% tar xvzf libiconv-1.8.tar.gz
% pushd libiconv-1.8/
% ./configure --mandir=/usr/local/share/man
% make
% sudo make install
% popd
3) Install mod_encoding (
This module improves non-ascii filename interoperability of apache (and mod_dav) and fix Windows XP authorization. See INSTALL for more details. Type the following in the Terminal:
 % curl -0
% tar xvzf mod_encoding-20020611a.tar.gz
% pushd mod_encoding-20020611a/
% ./configure --with-apxs=/usr/sbin/apxs
% make
% sudo make install
% popd
4) Enable WebDAV in the Apache Config File
Modify your httpd.conf in /private/etc/httpd/. I use vi to do it:
 % sudo vi /private/etc/httpd/httpd.conf
Add or uncomment in the beginning of httpd.conf (where you see LoadModules directives):
LoadModule headers_module  libexec/
LoadModule encoding_module libexec/

AddModule mod_headers.c
AddModule mod_encoding.c
Zoom down to the end of the file and add this text:
# Set DAVLockDB for webdav support

DAVLockDB /private/var/run/davlocks/DAVLockDB
Fix header for webdav#

BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "Microsoft-WebDAV-MiniRedir/5.1.2600" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS" redirect-carefully

<IfModule mod_headers.c>
Header add MS-Author-Via "DAV"

<IfModule mod_encoding.c>
EncodingEngine on
NormalizeUsername on
Save httpd.conf and exit.

5) Configure Webdav folder
Create Dav folder in Default root:
 % sudo mkdir /Library/WebServer/Documents/dav
% sudo chmod -R 775 /Library/WebServer/Documents/dav
Open httpd.conf again and zoom down to the end of the file and add this text:
Alias /dav /Library/WebServer/Documentsd/av
<Location /dav>
AuthType Basic
AuthName "WebDAV Restricted"
AuthUserFile /private/etc/httpd/passwords/webdav.access
require valid-user
Order allow,deny
Allow from all
Save httpd.conf and exit.

6) Create a user password
If it doesn't exist, create password dir in /private/etc/httpd:
 % sudo mkdir /private/etc/httpd/passwords
Then create a user named davuser1:
 % sudo htpasswd -c /private/etc/httpd/passwords/webdav.access
Provide a password when prompted.

7) Restart apache:
 % sudo apachectl graceful
And that's all, now you have webdav enabled. Open your webdav folder with this url: http://your_ip_number/dav

Useful links:
WevDAV install document
MacDevCenter article

Comments (38)

Mac OS X Hints