WebDAV support in Mac OS X (Public Beta 1) allows for simple remote management of Web content.
WebDAV, or "Web-based Distributed Authoring and Versioning," is a set of extensions to HTTP/1.1 ("HyperText Transfer Protocol," the protocol spoken by Web browsers and servers) allowing you to edit documents on a remote Web server. DAV provides support for:
DAV accomplishes this by adding to HTTP's standard GET and POST request types: DELETE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, etc.
WebDAV is platform independent, both in terms of client and server. This means that Macintosh, *nix, and Windows users can collaborate on Web content without all the usual conversion problems. Furthermore, it doesn't matter whether your documents are hosted on an Apache or Microsoft IIS server.
WebDAV is software agnostic. As long as your Web authoring tools are DAV compliant, it makes little difference which particular product you're using. More and more products are either already supporting or planning to support WebDAV. Microsoft's "Web Folders" are folders that for all intents and purposes appear to be on your local machine but are actually network connections to a remote server. Macintosh users have Goliath, an open source Finder-like application. WebDrive, a commercial application for Windows, provides three ways to connect to remote servers, via WebDAV, FTP, and Microsoft FrontPage's extensions.
WebDAV is (at least, should be) seamless. Because DAV is simply a set of extensions to HTTP, it's rather easy for companies to build support into any product that already "understands" the Web. And since DAV rides on top of HTTP, firewalls tend not to get in the way of accessing your Web content remotely. Of course, one should be sure to secure content by way of HTTP's existing authentication and authorization systems.
Mac OS X has support for WebDAV built right into the operating system and integrated seamlessly into the desktop environment. Simply point to a server, log in, and bingo!, you've a new virtual drive right on your desktop. It's even accessible at the Darwin *nix command prompt as just another directory.
Thankfully, OS X (Public Beta 1) also ships with a DAV-enabled copy of the famous Apache Web server, providing us with a nice simple test environment in which to explore WebDAV. Alright, so perhaps "capable" is more accurate than "enabled." The version of Apache shipping with OS X includes everything you need to use WebDAV; it only needs a little enabling. So let's do that first, shall we...
Greg Stein's wonderful mod_dav module is responsible for Apache's understanding of WebDAV. Enabling DAV in Mac OS X's Apache is simply a matter of editing the configuration file,
apache.conf (yes, that's
httpd.conf to everyone else in the universe
Note: In Step 2 of his instructions, Tom doesn't mention that you'll need to become the superuser ("root") in order to be able to edit the
apache.conf configuration file. The easiest way I found to accomplish this without making you use one of the sometimes confusing terminal-based text editors is as follows:
Open the Terminal application to gain access to Mac OS X's command-line.
Screen shot of terminal application.
Click on the smiley-mac Desktop icon at the left of the Dock at the bottom of your desktop. The Finder window should appear.
Click the Apps button at the top of the Finder window. If the toolbar isn't there, turn it on by holding down the Apple/Command key and hitting b on your keyboard.
Double-click Terminal. The dreaded command-line window
Become the root user by typing su and hitting the return key on your keyboard, followed by (unless you've changed it) the password you used to log into Mac OS X, and hit the return key again. You'll notice the prompt change from % to #.
[darwin:~] charles% su Password: [darwin:/Users/charles] root#
apache.conf using the handy GUI TextEdit application by typing:
at the command prompt. (This should all be on one line, not split as shown above for presentation purposes)
TextEdit appears with the contents of
apache.conf in the editing window. Edit as advised by http://osx.macnn.com/features/webdav.phtml, save your changes with Apple/Command-s and close TextEdit with Apple/Command-q when finished.
Be sure to un-root yourself by typing
exit at the command line prompt. To close the Terminal window, type
exit again (this time as yourself), and Apple/Command-q to close the application.
You're back! You should now have a Web server running on your desktop/laptop with WebDAV support. The bits in your
apache.conf file should look like:
LoadModule dav_module /System/Library/Apache/Modules/libdav.so ... AddModule mod_dav.c ... DAVLockDB /Library/WebServer/davlocks/DAVLockDB <Directory "/Library/WebServer/Documents"> DAV on
Of course, since we've not taken any security measures in our configuration file, your Documents directory is open for all to manipulate. You can limit access to your choice of a set of DAV functions by user, group, host, etc. Some common authentication and authorization methods are presented by Greg Stein at http://www.webdav.org/mod_dav/install.html#apache.
Also, in order for you to be able to write to the local server, you'll have to make sure that your Documents directory is writeable by the Web server user, www. Without access restrictions in place, this is not advisable -- you'll therefore not be able to make any changes to your content as we have things currently configured.
Now for the fun bit! Although it doesn't seem all that dramatic since we're only connecting to our local machine, just imagine that the server you're connecting to is halfway 'round the world from you -- the concept and method is the same.
Click anywhere on your desktop to bring up the Desktop context menubar at the top of the screen.
From the Go menu, select Connect to Server.... Surprisingly enough, the Connect to Server window appears.
Select Web Servers from the pull-down menu at the top-left of the window.
In the URL box, type
http://localhost/ and click the Connect button.
The connect dialog box.
Note: Had you limited access by user or group, you'd have been presented with a login dialog box, shown below.
The login dialog box appears if you limited access by user or group.
After a second or three, a Finder window will appear with a view on "localhost," your new networked drive. An icon for same will also appear on the desktop.
Finder window with view on localhost.
You can browse around, add, update, and delete anything for which you have permission to do so, just as on any local drive. For a tad more fun, use the Terminal application to meander about "localhost."
You can use Terminal to view "localhost."
It was immediately apparent to me how to unmount a networked disk. Logging out and back in again, and dragging the "localhost" icon to the wastepaper basket in the Dock did the trick -- albeit a little silly. Mac Help ... didn't!
There are still a few wobbly bits in Mac OS X's WebDAV support (as with the rest of the OS), but these are mostly on the annoying rather than BAD side.
The following is a list of starting points from which to explore further some of the topics covered (or not) in this article.
"HTTP Extensions for Distributed Authoring -- WEBDAV", IETF RFC 2518, Standards Track, Proposed Standard. February, 1999.
Limiting access by user or group on the local Apache WebDAV server seems to send the Connect to Server... functionality into a spin. I actually had to reboot my laptop with a paperclip since everything came to a standstill.
Disconnecting, as I mentioned above, is not particularly obvious. Dragging "localhost" to the trash produced a "The operation could not be completed because the disk is in use" warning despite the fact that it wasn't (in use, I mean). Donning my *nix hat and unmounting the drive from the command-line produced the same error. Using -f to force an unmount did the trick from the command-line, but left an unusable drive icon on the desktop.
OS X Brings Unix Stability to the Mac
Mac OS X Terms and Definitions
Macintosh News - from Meerkat
Discuss this article in the O'Reilly Network Forum.
Return to the O'Reilly Network..