How to Configure a WebDAV Folder on AlmaLinux 9

In this tutorial, well walk through configuring a WebDAV folder on AlmaLinux 9, one of the latest and most popular RHEL-based distributions.

WebDAV (Web Distributed Authoring and Versioning) is an extension of HTTP that allows clients to perform remote web content authoring operations. In simpler terms, it lets users access and manage files stored on a remote server as if they were on their local machines. This is especially useful for collaborative environments, remote file management, or personal cloud storage solutions.

In this article, we’ll walk through the steps to configure a WebDAV folder on AlmaLinux 9, a popular RHEL-based Linux distribution. We’ll use Apache HTTP Server as our WebDAV server, which provides a reliable and secure platform for hosting WebDAV services.


Prerequisites

Before diving into the setup process, ensure the following:

  • You have root or sudo privileges.
  • A clean AlmaLinux 9 system.
  • A basic understanding of Linux command-line tools.
  • An active network connection to access the WebDAV server from clients.

Step 1: Install Apache HTTP Server

WebDAV is implemented as a set of Apache modules. Begin by installing Apache.

sudo dnf install httpd -y

Once installed, enable and start the Apache service:

sudo systemctl enable httpd
sudo systemctl start httpd

Verify that Apache is running:

sudo systemctl status httpd

Step 2: Install WebDAV Modules

Apache uses the mod_dav and mod_dav_fs modules to support WebDAV. These are usually included with Apache by default on AlmaLinux, but you can verify their presence:

sudo httpd -M | grep dav

You should see output like:

dav_module (shared)
dav_fs_module (shared)

If for some reason they are not loaded, you can manually load them in Apache’s configuration by adding these lines to /etc/httpd/conf/httpd.conf:

LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so

Then restart Apache:

sudo systemctl restart httpd

Step 3: Create a WebDAV Directory

Next, create a directory on the server that you want to expose via WebDAV:

sudo mkdir -p /var/www/webdav
sudo chown apache:apache /var/www/webdav
sudo chmod 755 /var/www/webdav

This folder will serve as the root of your WebDAV service.


Step 4: Configure Apache for WebDAV

Now, configure a virtual host or location in Apache to serve WebDAV content.

Create a new configuration file, for example:

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

Add the following configuration:

Alias /webdav /var/www/webdav

<Directory /var/www/webdav>
    DAV On
    Options Indexes
    AuthType Basic
    AuthName "WebDAV Secure Area"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
</Directory>

This configuration does the following:

  • Maps /webdav in your browser to /var/www/webdav on the server.
  • Enables WebDAV (DAV On).
  • Sets up basic authentication.
  • Specifies the file containing user credentials.

Step 5: Create WebDAV User Authentication

For security, it’s essential to restrict access with authentication. You’ll need the httpd-tools package, which provides the htpasswd utility:

sudo dnf install httpd-tools -y

Create a user for WebDAV access:

sudo htpasswd -c /etc/httpd/.htpasswd username

Replace username with your preferred username. You’ll be prompted to enter a password. The -c flag creates the file, so only use it the first time. To add additional users, omit the -c.

Ensure proper permissions on the password file:

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

Step 6: Configure SELinux and Firewall

If SELinux is enabled (which it is by default on AlmaLinux 9), you must allow Apache to write to the WebDAV directory.

Set the proper SELinux context:

sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/webdav(/.*)?"
sudo restorecon -Rv /var/www/webdav

If semanage is not installed, get it via:

sudo dnf install policycoreutils-python-utils -y

Open the Firewall

Allow HTTP (and optionally HTTPS) traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Step 7: Restart Apache

With everything configured, restart Apache to apply all changes:

sudo systemctl restart httpd

Step 8: Access WebDAV from Client

Your WebDAV service should now be up and running. You can access it from your browser or using WebDAV clients like:

  • Windows File Explorer: Map network drive → Enter http://your_server_ip/webdav
  • Linux: Use davfs2, nautilus, cadaver, or curl
  • macOS: Finder → Connect to Server → Enter http://your_server_ip/webdav

When prompted, use the username and password you created earlier.


Step 9: (Optional) Enable HTTPS for Secure Access

Using WebDAV over HTTP is not secure, as credentials are transmitted in plain text. Enabling HTTPS is strongly recommended.

Install SSL Module and Certbot

sudo dnf install mod_ssl -y
sudo dnf install epel-release -y
sudo dnf install certbot python3-certbot-apache -y

Get a Free SSL Certificate from Let’s Encrypt

sudo certbot --apache

Follow the prompts to issue and configure the certificate for your domain.

Once done, ensure automatic renewal is working:

sudo systemctl list-timers | grep certbot

Step 10: Automount WebDAV on Client (Linux Example)

To automatically mount WebDAV on Linux using davfs2, install the package:

sudo dnf install davfs2 -y

Edit /etc/fstab to include:

http://your_server_ip/webdav /mnt/webdav davfs noauto,user 0 0

Create the mount point:

sudo mkdir -p /mnt/webdav

Mount the directory:

mount /mnt/webdav

If you want user-based mount, configure ~/.davfs2/secrets:

http://your_server_ip/webdav username password

Conclusion

Setting up a WebDAV folder on AlmaLinux 9 using Apache is a straightforward and powerful way to share files over the web. With proper authentication, optional SSL encryption, and user access control, you can create a robust and secure file hosting solution for yourself, your team, or even your organization.

Let’s recap the main steps:

  1. Install Apache and WebDAV modules.
  2. Set up the directory structure and permissions.
  3. Configure authentication.
  4. Secure the server with SELinux, firewalls, and HTTPS.
  5. Connect and test from client machines.

Whether you’re using it for personal cloud storage, remote web authoring, or internal collaboration, WebDAV is a time-tested and reliable protocol that works well with the flexibility of AlmaLinux.