How to enable WebDAV on Apache HTTP Server 2.4.x

A couple of time already, I had to go through the process of enabling WebDAV on Apache HTTP Server 2.4.x and even though it is a fairly simple thing to do, I always end up Googling around a proper working solution. Here are the steps…

I am using Amazon Linux 4.14.88-72.76.amzn1.x86_64 on x86_64 as my host OS, but that shouldn’t be relevant.

Following are the steps for Apache version 2.4.37 configuration.

Open your httpd.conf Apache configuration file, which will most likely reside at /etc/httpd/conf/ directory and make sure you’re loading the configuration modules that came preinstalled with Apache 2.4. The following line should be in the config line: Include conf.modules.d/*.conf

If there, then just make sure that in /etc/httpd/conf.modules.d you have all the config files, particularly one called: 00-dav.conf

Open 00-dav.conf and double check that it contains the following lines that enable WebDAV modules and that they’re not commented out.

Now that we have taken care of the configuration, create a directory where you will host your, I did that in the following directory:  /var/www/html/webdav

And set the proper rights on the folder:

All of the above can be also done by running these commands with the sudo privileges.

When done, let’s create a user called ‘webdavuser’ for WebDAV and set up a password for the new user:

If you open .htpasswd file, you should see your new user added in along with the password:

Then increase security by setting the permission on the password file:

Now you can change the virtual host configuration of the domain where you want to serve WebDAV files. First, enable the location for the DAV lock database, it must be specified in the global section of httpd.conf file using the DavLockDB directive. Then add the alias for WebDAV directory and Directory directives into your virtual host. When completed, it’ll look something like this:

Restart Apache server and see if you can visit your domain.com/webdav it should now be available. You will be presented with the request for the username and password we’ve set up for WebDAV user (webdavuser), just type it in:

 

If everything is setup correctly, you’ll see the WebDAV folder structure:

Enjoy!

 

Facebook Comments