Apache Howto WebDAV

From openSUSE

This README describes how to set up a WebDAV server, using Digest Authentication.

The following script should serve both as an introductory example how it is done, as well as a copy & paste template for you. You could copy the bits step by step, while reviewing them and adjusting them for your needs.

 # enable needed apache modules:
 /usr/sbin/a2enmod dav
 /usr/sbin/a2enmod dav_fs
 /usr/sbin/a2enmod auth_digest
 
 # Define directory to be accesed:
 davdir="editme"
 # Define a location where the credentials are stored:
 acldir=ACL
 auth_realm=$davdir
 
 cd /srv/www
 
 # create a directory for WebDAV access:
 mkdir $davdir
 chmod 770 $davdir
 chown root:www $davdir
 
 # create the directory for the credentials:
 mkdir $acldir
 chmod 750 $acldir
 chown root:www $acldir
 
 # create credentials file:
 touch $acldir/$davdir
 chown root:www $acldir/$davdir
 chmod 640 $acldir/$davdir
 
 # set up a user account
 htdigest2 $acldir/$davdir $auth_realm  ${user:-user1}
 
 
 cat <<EOF
 #
 # Put this into /etc/apache2/conf.d/$davdir.conf:
 #
 
 EOF
 
 cat <<EOF
 
 
 # This directive is always needed, if you use WebDAV.
 # see http://httpd.apache.org/docs-2.2/mod/mod_dav_fs.html#davlockdb
 <IfModule mod_dav_fs.c>
         DavLockDB /var/lib/apache2/DAVLock
 </IfModule>
 
 <IfModule mod_dav.c>
 <IfModule mod_dav_fs.c>
         Alias /$davdir /srv/www/$davdir
         <Location /$davdir>
                 DAV On
                 #ForceType text/plain
 
                 Order Deny,Allow
                 Deny from all
 
                 AuthType Digest
                 AuthName "private area"
 
                 AuthDigestFile /srv/www/ACL/$davdir
                 AuthDigestDomain /$davdir/
                 AuthName $auth_realm
 
                 Require valid-user
                 Satisfy Any
         </Location>
 </IfModule>
 </IfModule>
 
 EOF