How to Set up WebDAV with Apache2 on CentOS 5.5

WebDAV stands for web-based Distributed Authoring and Versioning and is a set of extensions to the HTTP protocol that allow users to directly edit files on the Apache server so that they do not need to be downloaded/uploaded via FTP. Of course, WebDAV can also be used also be used to upload and download files.

Afterwards, open /etc/httpd/conf/httpd.conf and make sure that the dav and dav_fs modules are enabled in the LoadModule section (they should be enabled by default):

Add the below lines:

Then create the system startup links for Apache and start it:

Virtual Host Configuration:

Now create virtualhost configuration for the foloder you want to share by WebDAV. In my case I am using /var/www/html/test. Also I am using the httpd global configuration for my vhost. If you have separate vhost configuraiton file for the folder then you can use that one.

First, we have to create the directory /var/www/html/test and make the Apache user and group (apache) the owner of that directory:

Then add the new vhost at the end of /etc/httpd/conf/httpd.conf:

Reload Apache to reflect the new configuration

Configure The Virtual Host For WebDAV

Now we create the WebDAV password file /etc/httpd/conf.d/passwd.dav with the user Admin (the -c switch creates the file if it does not exist):

You will be asked to type in a password for the user Admin.

(Please don’t use the -c switch if /etc/httpd/conf.d/passwd.dav is already existing because this will recreate the file from scratch, meaning you lose all users in that file!)

Now we change the permissions of the /etc/httpd/conf.d/passwd.dav file so that only root and the members of the apache group can access it:

Now we modify our vhost at the end of /etc/httpd/conf/httpd.conf and add the following lines to it:

The Alias directive makes (together with <Location>) that when you call /webdav, WebDAV is invoked, but you can still access the whole document root of the vhost. All other URLs of that vhost are still “normal” HTTP.

Reload Apache afterwards:

Testing WebDAV

We will now install cadaver, a command-line WebDAV client:

To test if WebDAV works, type:

You should be prompted for a user name. Type in Admin and then the password for the user Admin. If all goes well, you should be granted access which means WebDAV is working ok. Type quit to leave the WebDAV shell:

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

One thought on “How to Set up WebDAV with Apache2 on CentOS 5.5

  1. When someone writes an paragraph he/she keeps the plan of a user in his/her mind that how
    a user can understand it. So that’s why this article is perfect. Thanks!

Leave a Reply