Just experimented with the joys of WebDAV and remote editing. I put my website under source control last night, not unlike the way we do it at Apache. Then I got to thinking, that deploy step is just a hassle, why can’t I just edit the content on the server? Come to find out, I can. This is great. The following is a mini-HOWTO on WebDAV with Apache2 and Mac OS X:
Edit your httpd.conf to include the mod_dav (WebDAV) and mod_dav_fs (filesystem based store) modules:
LoadModule dav_fs_module modules/mod_dav_fs.so
Then we also add the mod_dav_fs lock database statement:
Make sure to set this to a drectory (/www/var here) that is writable by the user AND group of the Apache process (nobody:nobody for me).
Then we go into some website config, and add the magic incantations that export the website as editable:
<Location /source>
Dav On
ForceType text/plain
AuthType Basic
AuthName “dotnot.org”
AuthUserFile “/www/dotnot.org/.htpasswd”
Require valid-user
</Location>
Now for some explanation. Since I have static and dynamic content on my site (who wouldn’t), I have aliased the ‘/source’ URI so I can edit both types of content. The ‘Dav On’ statement tells the mod_dav module to get to work on this directory. To prevent dynamic content from being executed, the ForceType directive tells Apache to just spit out the raw conent (text) of the files. This means index.php will be the source instead of the result. The Auth* directives say that I want to authenticate the users that access this resource, as does the Require directive.
So now we have Apache setup correctly, we restart it (apachectl restart), and go to test it. How?, you ask. Simple: Jaguar. Mac OS X (I am using Jaguar 10.2.6) has WebDAV filesystem connections included in the OS (this is how they connect to your iDisk on your .mac account)! This is going to be too easy. Just open a finder window, click command+K (Connect), type http://dotnot.org/source (your URL will be different of course) into the address box, click connect, and we are done. On the Mac, we find this info under /Volumes/source, and we can just copy, delete and edit files in there, all the time editing the remote content. This is too cool.
A few comments before you go crazy remote-enabling everything, a couple of warnings: First, this method is only as fast as the network connection it is operating on. So mass updates should probably be done locally, and batched up. Second, you are editing the live content. This means there is no backup, unless you make one. I would highly reccomend using some soure control product, such as Subversion (which uses WebDAV by the way) to keep archives of the files. And finally, this should work on Windows as well (using WebFolders and IIS), but that is not my setup. I would be happy to post similar information on how to do this on Windows.
Feedback appreciated.
Popularity: 9%