How To Set up WebDAV using Apache on CentOS 7

Set up WebDAV using Apache on CentOS 7

In this tutorial, we will show you how to Set up WebDAV using Apache on CentOS 7 server. For those of you who didn’t know, 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 webserver. This makes WebDAV a favourite choice for programmers, especially when combined with Subversion or Git.

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 the Apache webserver.

Install Apache using YUM:

yum install httpd

Start the Apache webserver:

systemctl start httpd.service
systemctl enable httpd.service

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

httpd -M | grep dav

You should 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
<VirtualHost *:80>
 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
 <Directory /var/www/html/webdav>
 DAV On
 AuthType Basic
 AuthName "webdav"
 AuthUserFile /etc/httpd/.htpasswd
 Require valid-user
 </Directory>
</VirtualHost>

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 favourite browser and navigate to http://mydomain.com/webdav and complete the required steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulations! 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 website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!