WebDAV stands for Web Distributed Authoring and Versionin, see RFC 2518.
WebDAV is an extension of HTTP 1.1 and therefore can be considered to be a procotol. It contains a set of concepts and accompanying extension methods to allow read and write across the HTTP 1.1 protocol. Instead of using NFS or SMB, WebDAV offers file transfers via HTTP.
The goal of this how to is to setup a simple WebDAV configuration using Apache.
See also File Sharing with Webdav and DNSSD.
Install Apache as explained in the LAMP article.
Now enable WebDAV. Add the following line to
Make sure you add it outside of any other directives, for instance right under the
Next, add the following (also outside of any directives):
<Directory "/home/httpd/html/dav"> DAV On AllowOverride None Options Indexes FollowSymLinks Order allow,deny Allow from all </Directory>
# mkdir -p /home/httpd/DAV # chown -R http:http /home/httpd/DAV # Otherwise you wouldn't be able to upload files # mkdir -p /home/httpd/html/dav # chown -R nobody.nobody /home/httpd/html/dav
is a command line WebDAV client.
# pacman -S cadaver
# cadaver http://localhost/dav dav:/dav/> mkcol test Creating `test': succeeded. dav:/dav/> ls Listing collection `/dav/': succeeded. Coll: test dav:/dav/> exit
If the above worked as shown, then you are good to go.
500 Internal Server Error
dav:/dav/> mkcol test Creating `test': failed: 500 Internal Server Error
This means DAV locking is not enabled you can see the following error-messages in Apache's error-log:
[Fri Feb 22 14:51:42 2013] [error] [client ::1] The locks could not be queried for verification against a possible "If:" header. [500, #0] [Fri Feb 22 14:51:42 2013] [error] [client ::1] Could not open the lock database. [500, #400] [Fri Feb 22 14:51:42 2013] [error] [client ::1] (2)No such file or directory: Could not open property database. [500, #1]
So just setup write permissions by changing ownership of DavLockDB's directory "/var/lock/dav" to the apache-user. If the directory does not exist, simply create it.
- mkdir /var/lock/dav
- chown http:http /var/lock/
Make sure you add permissions for viewing and dav access to the directory, and maybe even make that directory ssl access only.
There are numerous different protocols you can use:
Two examples follow, in which
foo is the username:
# basic form: htdigest -c /path/to/file AuthName username htdigest -c /etc/httpd/conf/passwd WebDAV foo
# basic form: htpasswd -c /path/to/file username htpasswd -c /etc/httpd/conf/passwd foo
httpd.conf must be edited to enable authentication. One method would be to require the user
foo for everything:
<Directory "/home/httpd/html/dav"> DAV On AllowOverride None Options Indexes FollowSymLinks Order allow,deny AuthType Digest # substitute "Basic" for "Digest" if you used htpasswd above AuthName "WebDAV" AuthUserFile /etc/httpd/conf/passwd Require user foo Allow from all </Directory>
If you want to permit everybody to read, you could use this in your httpd.conf
<Directory "/home/httpd/html/dav"> DAV On AllowOverride None Options Indexes FollowSymLinks Order allow,deny AuthType Digest # substitute "Basic" for "Digest" if you used htpasswd above AuthName "WebDAV" AuthUserFile /etc/httpd/conf/passwd Allow from all <LimitExcept GET HEAD OPTIONS PROPFIND> require user foo </LimitExcept> </Directory>
Don't forget to restart apache after making changes!
# systemctl restart httpd