Personal blog for expressing my experiences

Technology

Setup WebDAV with Apache

This is a small tutorial in setting up WebDAV with Apache2. I have implemented it on Centos 5.0.

WebDAV – Web-based Distributed Authoring and Versioning, allows one user to edit the files directly on the server rather than downloading and then uploading the files to the server. Install `apache` web server. Just need to make some changes in the `httpd.conf` file.

Enable the following modules in the `httpd.conf` file.


LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so

Noe, you need to create the directory where you want users to upload the files. Suppose I assume that you have a partition `/data` on the server.

root@ophiophagus:~#mkdir backup <- inside the /data partition.

Ensure that the ownership for the /data parition is `apache`.

Now you need to create a virtual host entry for the `WebDAV`. Before that, create the WebDAV username/password file.

root@ophiophagus:~#htpasswd -c /data/backup/passwd.dav testuser

Change the ownership as well as the permission of the file. Now create a virtual host entry for the directory.

<VirtualHost *:80>
ServerName ophiophagus.blog.co.in
ServerAdmin prasanta@ophiophagus
DocumentRoot /data/

<Directory /data/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

Alias /backup /data/backup
<Location /backup>
DAV On
AuthType Basic
AuthName “Admin Server”
AuthUserFile /data/backup/passwd.dav
Require valid-user
</Location>
</VirtualHost>

Just reload `httpd`.

There is a utility tool for testing WebDAV from command line. Download and install and application called `cadaver`.

prasanta@ophiophagus:~$cadaver http://ophiophagus.blog.co.in/backup/
Authentication required for webdav on server `Admin Server’:
Username: testuser
Password:
dav:/webdav/> ls

This will list the files which are there in the particular directory.

Note: I am still looking for a option to limit the user file upload, depending upon the file type extension, but I still not able to figure this out.

Leave a Reply

6  +  2  =