How to Setup Apache WebDAV Server Access on Ubuntu 20.04

How to Setup Apache WebDAV Server Access on Ubuntu 20.04. In this guide we will introduce WebDAV, how its works then move onto the installation phase on Ubuntu 20.04.

Suppose you visit a webpage through some hyperlink. You can edit that page if it is in the form of a shared document or on a wiki knowledgebase website. However, if it is in the read only format, it is not possible to edit them. This is where WebDav comes into the picture.

Let’s find out more about WebDAV, it’s features and how to Setup Apache WebDAV Server Access on Ubuntu 20.04.

What is WebDAV?

WebDAV or Web Distributing, Authoring, and Versioning is an extension to HTTP that enables you to edit remote content on the web. It allows web servers to act as file servers so that authors can collaborate on web content.

In essence, it provides basic functionality like sharing, copying, moving and editing files through a web server. It also supports collaborative applications by providing file locking and revision tracking features.

It improves the standard set of HTTP headers and methods so that you can move, create and edit files and folders. Being an extension to HTTP, it generally uses port 80 for plain unencrypted access and port 443 while using SSL/TLS protocol.

Moreover, while you may be aware of file access and manipulation, you do not know about tracking revisioning. With WebDAV it constitutes a versioning system that includes revisioning.

How WebDAV Works?

WebDAV extends HTTP headers to communicate with the server. It includes the new headers that are as follows:

  • COPY – used for copying resources.
  • MKCOL – used for creating a collection, such as folders.
  • PROPPATCH – used for changing or removing properties.
  • UNLOCK – used for removing a lock from a resource.
  • LOCK – used for putting a lock on a resource.
  • PROPFIND – used for retrieving properties stored as XML.
  • MOVE – used for moving a resource.

Other key attributes provided by WebDAV are:

  • Integration of operating system.
  • Free to use.
  • Closely integrated with web services.
  • Transport encryption.
  • Version control.

Therefore, WebDAV is a protocol that has been able to provide services like project management, collaborative authoring, development coordination, telecommuting, and cloud services with ease.

In this post, we will show you how to install the WebDAV server on Ubuntu 20.04.

How to Setup Apache WebDAV Server Access on Ubuntu 20.04


  • A server running Ubuntu 20.04.
  • A root user or a user with sudo privileges.

Install Apache Web Server

Before starting, you will need to install the Apache web server on your system. By default, the Apache server package is included in the Ubuntu default repository. You can install it by running the following command:

					apt-get install apache2 -y

Once the Apache server package is installed, start and enable the Apache service with the following command:

					systemctl start apache2
systemctl enable apache2

You can check the status of the Apache with the following command:

					systemctl status apache2

You should see the following output:

					● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-07-28 07:32:36 UTC; 4s ago
    Process: 16287 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 16300 (apache2)
      Tasks: 55 (limit: 2347)
     Memory: 4.9M
     CGroup: /system.slice/apache2.service
             ├─16300 /usr/sbin/apache2 -k start
             ├─16301 /usr/sbin/apache2 -k start
             └─16302 /usr/sbin/apache2 -k start

Jul 28 07:32:36 linux systemd[1]: Starting The Apache HTTP Server...

You can also verify the Apache version using the following command:

					apache2ctl  -v

You should see the following output:

					Server version: Apache/2.4.41 (Ubuntu)
Server built:   2022-06-14T13:30:55

Create Directory Structure for WebDAV

Now you will need to create a directory for WebDAV that you want to share to your users. Run the following command to create a WebDAV directory inside the Apache web root:

					mkdir /var/www/html/webdav

Then change the ownership of the WebDAV directory to www-data:

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

And create a directory to store the WebDAV database file:

					mkdir -p /usr/local/apache/var/
chown www-data:www-data /usr/local/apache/var

After creating WebDAV directory structure, you can proceed to configure Apache to serve WebDAV.

Create an Apache Virtual Host for WebDAV

Following step is to create an Apache virtual host configuration file to serve WebDAV folder via internet. You can create it with the following command:

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

Add the following lines:

					DavLockDB /usr/local/apache/var/DavLock

<VirtualHost *:80>
        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


Save and close the file then activate the Apache virtual host using the following command:

					ln -s /etc/apache2/sites-available/webdav.conf /etc/apache2/sites-enabled/

The WebDAV is Apache’s default features. So in order to use this feature, you will need to enable the WebDAV modules to activate its functionality. You can enable both WebDAV modules with the following command:

					a2enmod dav
a2enmod dav_fs

Please restart the Apache service to apply the configuration changes:

					systemctl restart apache2

Enable WebDAV Authentication

For security reasons, it is recommended to protect the WebDAV share with username and password. In order to enable the WebDAV authentication, firstly create a file to store the WebDAV password:

					touch /usr/local/apache/var/users.password
chown www-data:www-data /usr/local/apache/var/users.password

Secondly create a user for WebDAV using the following command:

					htdigest /usr/local/apache/var/users.password webdav webadmin

You will be asked to set your password as shown below:

					Adding user webadmin in realm webdav
New password: 
Re-type new password: 

Once the WebDAV user is created, you will need to edit the WebDAV configuration file and enable the WebDAV authentication. You can edit it with the following command:

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

Add the following lines after the line “DAV On”:

					AuthType Digest
AuthName "webdav"
AuthUserFile /usr/local/apache/var/users.password
Require valid-user

Save and close the file then enable the Digest module and restart the Apache service with the following command:

					a2enmod auth_digest
systemctl restart apache2

A brief explanation of each directive is shown below:

  • AuthType Digest: Used to define the authentication method.
  • AuthName “webdav”: Define which users are allowed from the webdav realm.
  • AuthUserFile /usr/local/apache/var/users.password: Define the username and password location to access the WebDAV.
  • Require valid-user: Allow only users listed in the users.password file.

At this point, the WebDAV server is installed and configured with authentication. You can now proceed to access the WebDAV share from the remote machine.

Access WebDAV

There are several ways to connect to the WebDAV server, such as File manager, Web browser, Command line, WebDrive. WinSCP, Cyberduck and others can work with multiple protocols.

Before accessing the WebDAV, create some files inside the WebDAV directory.

					touch /var/www/html/webdav/file1.txt
touch /var/www/html/webdav/file2.txt
touch /var/www/html/webdav/file3.txt

Thereafter change the ownership of all files using the following command:

					chown -R www-data:wwww-data /var/www/html/webdav/*

Access WebDAV from Ubuntu Desktop

Open your File Manager, press the CTRL + L and type the URL dav:// as shown below:

Hit the Enter key. You will be asked to provide WebDAV username and password:

Provide your admin username, password and click on the Connect button. You should see the content of the WebDAV directory on the following screen:

Once you are login to the WebDAV server, you can perform the several things, including Create a new file, Create a folder, Edit an existing file, Delete a file, Delete a folder, Copy or Move files between a local folder and a remote folder on the server, Put a lock on a resource, Remove a lock from a resource and many others.

Access WebDAV via Command Line

Additionally WebDAV also allows you to access it via command line interface. Command line method is very useful when you are working on the server without Desktop manager. It helps system administrator to easily access and manage the WebDAV share.  To access the WebDAV via command line, you will need to install the davfs package on your  server.

By default, the devfs package is included in the Ubuntu default repository. You can install it easily by running the following command:

					apt-get install davfs2

Once the devfs package is installed,  you will need to mount the WebDAV share to the local folder in order to use it. You can mount the WebDAV directory on the /mnt directory using the following command:

					mount.davfs /mnt

You will be asked to provide your WebDAV username and password:

					Please enter the username to authenticate with server or hit enter for none.
  Username: webadmin
Please enter the password to authenticate user webadmin with server or hit enter for none.

After the successful authentication, you can verify the content of WebDAV directory using the following command:

					ls /mnt/

You should see the following output:

					file1.txt  file2.txt  file3.txt

You can now easily copy and remove files to and from the WebDAV share directory via command line.

Secure WebDAV Access with Let's Encrypt SSL

It is a good idea to secure the WebDAV access with Let’s Encrypt SSL certificate so every communication done through secure channel. To do so, you will need to install the Certbot client in your system.

You can install the Certbot with the following command:

					apt-get install certbot python3-certbot-apache -y

Once the Certbot client has been installed successfully, run the following command to install the Let’s Encrypt SSL for your website:

					certbot --apache -d

You will be asked to provide your valid email and accept the term of service as shown below:

					Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at You must
agree in order to register with the ACME server at
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/webdav-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/webdav-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/webdav-le-ssl.conf

Select whether or not to redirect HTTP traffic to HTTPS or configure Apache to redirect all traffic to secure HTTPS access as shown in the following output:

					Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2


Type 2 and hit Enter to start the process. Once the installation is completed, you should get the following output:

					Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/webdav.conf to ssl vhost in /etc/apache2/sites-available/webdav-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled

You should test your configuration at:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 - Congratulations! Your certificate and chain have been saved at:
   Your key file has been saved at:
   Your cert will expire on 2022-09-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:
   Donating to EFF:          


You can now access your WebDAV share securely via HTTPS protocol.

Thank you for reading how to Setup Apache WebDAV Server Access on Ubuntu 20.04.

How to Setup Apache WebDAV Server Access on Ubuntu 20.04 Conclusion

In this guide, we explained how to setup a WebDAV server on Ubuntu 20.04. To conclude WebDAV is very useful for developers to download and upload code on the Webserver. Using WebDAV, you can easily access and manage the files in your WebDAV server from the central location.

Take a look at more Apache content here.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

5 2 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x