How To Set up WebDAV using Apache on CentOS 7

WebDAV (Web-based Distributed Authoring and Versioning) is an Extension of the HTTP protocol that allows users to edit and manage files and documents stored on servers.

WebDAV provides a frame for users to create, alter, move, Upload, and download documents on an Apache web server. This makes WebDAV a favorite choice for programmers, especially when combined with Subversion or Git.

Table of Contents

Step 1. First let’s start by ensuring your system is up-to-date.

Step 2. Installing Apache web server.

Step 3. Configure WebDAV.

Step 4. Configure Apache vhost for WebDAV.

Step 5. Accessing WebDAV.

 

Prerequisites

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step set up WebDAV using Apache on CentOS 7 server.
Set up WebDAV using Apache on CentOS 7

Step 1. First let’s start by ensuring your system is up-to-date.

yum clean all
yum -y install epel-release
yum -y update

Step 2. Installing Apache web server.

Install Apache using YUM:

yum install httpd

Start the Apache web server:

systemctl start httpd.service
systemctl enable httpd.service

For Apache, there are three WebDAV-related modules which will be loaded by default when a Apache web server getting started. You can confirm that with this command:

httpd -M | grep dav

You should be result with:

dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)

Step 3. Configure WebDAV.

After installing the WebDAV module, you will need to create a webdav directory:

mkdir /var/www/html/webdav
chown -R apache:apache /var/www/html
chmod -R 755 /var/www/html

Set up password authentication:

htpasswd -c /etc/httpd/.htpasswd chedelics

Now, you need to assign group ownership of the file to the apache user, and lock down the permissions for everyone else. To do this, run the following command:

chown root:apache /etc/httpd/.htpasswd
chmod 640 /etc/httpd/.htpasswd

Step 4. Configure Apache vhost for WebDAV.

Next, you need to create a virtual host file for the webdav directory:

nano /etc/httpd/conf.d/webdav.conf

Add the following content:

DavLockDB /var/www/html/DavLock

 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/html/webdav/
 ErrorLog /var/log/httpd/error.log
 CustomLog /var/log/httpd/access.log combined
 Alias /webdav /var/www/html/webdav
 
 DAV On
 AuthType Basic
 AuthName "webdav"
 AuthUserFile /etc/httpd/.htpasswd
 Require valid-user
 

Save and exit, Restart Apache to put your changes into effect:

systemctl restart httpd.service

Step 5. Accessing WebDAV.

WebDAV will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://mydomain.com/webdav and complete the required the steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulation’s! You have successfully installed WebDAV using Apache on CentOS 7. Thanks for using this tutorial for set up WebDAV using Apache on CentOS 7 systems. For additional help or useful information, we recommend you to check the official WebDAV web site.

Leave a Reply