How to Set Up Webdav with Apache on Ubuntu

WebDAV, also known as “Web-based Distributed Authoring and Versioning”, is an extension of the Hypertext Transfer Protocol. It allows users to collaboratively edit and manage files on a remote web server using HTTP protocol. You can share Word or Excel documents or a music collection with your friends and other people by simply giving them a URL. WebDAV also allow us to upload and download files on the Apache server. There are several benefits of WebDAV over other solutions such as FTP or Samba.

In this article I will explain how to install and configure WebDav with the Apache2 Web Server on Ubuntu-14.04.

By default the WebDAV module comes with apache2 installation in Ubuntu-14.04. However, it is not enabled by default.

You need to enable it first. You can enable the WebDAV modules using the a2enmod command.

sudo a2enmod dav
sudo a2enmod dav_fs

This will create a symbolic link from “/etc/apache2/mods-available” to “/etc/apache2/mods-enabled.”

Now, restart Apache to activate the new configuration.

sudo /etc/init.d/apache2 restart

After enabling the module, you will need to create the required directory where you will configure webdav.

Now, create a directory under Apache web root.

sudo mkdir /var/www/html/webdav

You will also need to change the permission in order to allow Apache to write to it.

sudo chown -R www-data:www-data /var/www/html/webdav

A WebDAV server without authentication is not secure. It is recommended to add authentication to your WebDAV server.

You need to create an authentication procedure for accessing the directory content by creating an htpasswd file.

Create a hidden .htpasswd file in the “/etc/apache2” configuration directory with the user “webuser.”

sudo htpasswd -c /etc/apache2/.htpasswd webuser

Now you need to assign group ownership of the file to “www-data,” and then lock down the permissions for everyone else:

sudo chown www-data:www-data /etc/apache2/.htpasswd
sudo chmod 640 /etc/apache2/.htpasswd

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

To do so, navigate to “/etc/apache2/sites-available/”:

cd /etc/apache2/sites-available/

Create a new site configuration file called “webdev.conf.”

sudo nano /etc/apache2/sites-available/webdav.conf

Add the following content:

DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/webdav/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        Alias /webdav /var/www/html/webdav
        <Directory /var/www/html/webdav>
            DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user

After creating the virtual host files, you need to enable a new virtual host.

You can do this by running:

sudo a2ensite webdav.conf

Now, restart Apache to activate the new configuration.

sudo /etc/init.d/apache2 restart

Finally, you need to test whether WebDav is properly enabled or not.

Open your favorite web browser and navigate to the url “http://your-server-ip/webdav/.” You will be prompted with a username and password to access the web page.


On your Ubuntu Linux machine, open the file manager and press the “Connect to Server” option on the left sidebar. Type the server address “dav://your-server-ip/webdav/,” and press Enter.


You will be prompted for a username and password. Enter them and press Connect.


Once you have connected, the directory should appear under the file manager.


In this article we have gone through how to configure webdav with the Apache server. Now, you have enough knowledge to configure it in production environment. Feel free to comment below if you have any questions.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.