Setting up WebDAV with Apache2
Setting up WebDAV with Apache2
2011
The content of the shared directory will be available for downloading in a web browser, and it’s possible to mount it as a drive on your desktop. I used Mac OS X 10.7.2 Lion which includes Apache 2.2.0, but this should also work on other platforms and with different versions of Apache. With the following steps, I managed to create the shared directory:
1.Create a user database for users who may access the share:
% sudo htdigest -c /var/webdav.passwd FileSharing testuser
2. Create the directory in the file system which should be shared:
% mkdir /Library/WebServer/Documents/FileSharing
% sudo chmod 777 /Library/WebServer/Documents/FileSharing
3.Create a directory and file for the WebDAV lock:
% sudo mkdir /var/davlock
% sudo chown -R _www /var/davlock
% sudo chgrp -R _www /var/davlock
% sudo touch /var/davlock/DAVLockDB
% sudo chmod 777 /var/davlock/DAVLockDB
4.Extend /etc/apache2/httpd.conf by adding the following text somewhere:
DavLockDB /var/davlock/DAVLockDB
Alias "/filesharing" "/Library/WebServer/Documents/FileSharing"
<Directory "/Library/WebServer/Documents/FileSharing">
Dav On
AllowOverride None
Options Indexes
Order allow,deny
Allow from all
AuthType Digest
AuthName FileSharing
AuthUserFile "/var/webdav.passwd"
Require valid-user
</Directory>
5.Make sure the httpd.conf contains the two following lines and that they are not commented-out (i.e. not prepended by #):
LoadModule dav_module libexec/apache2/mod_dav.so
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
That’s it. Re-start the web server with...
% sudo /usr/sbin/apachectl restart
...and test if you can access the shared directory!
Writeable shared directory with apache
08.01.2012
An easy way to set up file sharing over the web (if you don’t want to use FTP) is via WebDAV in Apache2. This is how to do it.