How To Setup WebDAV With Apache Web Server on Fedora 21

May 12, 2015 | By in LINUX HOWTO, WEB SERVERS
| 1 Reply More

Hi everyone, today we'll learn how to setup WebDav with Apache2 Web Server on Fedora 21 Operating System. WebDAV stands for "Web-based Distributed Authoring and Versioning". It is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers. The WebDAV protocol makes the Web a readable and writable medium. It provides a framework for users to create, change and move documents on a server; typically a web server or web share. The most important features of the WebDAV protocol include the maintenance of properties about an author or modification date, namespace management, collections, and overwrite protection. Maintenance of properties includes such things as the creation, removal, and querying of file information.

Here are some quick and easy steps  to setup WebDav with Apache Web Server on Fedora 21.

 1. Installing Apache Web Server

First of all, we'll need to make sure that Apache Web Server is installed on our system. If its not installed, we'll need to install by running the following command.

$ sudo yum install httpd

Installing httpd on fedora

Now, after we install Apache Web Server, we'll want to enable it to startup in every boot and start the service.

$ sudo systemctl enable httpd.service
$ sudo systemctl start httpd.service

Enabling httpd

2. Configuring WebDav Directory

After installing Apache Web Server, we'll now create the required directory where we'll configure webdav in. Here, we've choosed /var/www/linoxide/webdav as WebDav enabled directory.

$ sudo mkdir -p /var/www/linoxide/webdav

Then, we'll want to make user "apache" having group "apache" as the owner of the directory using the following command.

$ sudo chown apache:apache /var/www/linoxide/webdav

configuring webdav directory

3. Setting Password Protection

We can create an authentication procedure for accessing the directory content by creating an htpasswd file. To create it, we need to run the following command in a shell or a terminal.

$ sudo htpasswd -c /var/www/linoxide/passwd.dav admin

Note: Here, admin is a username, you can change it as per the security.

After running the above command, we'll be asked to enter a password for the user admin .

setting password protection

Right now, anyone can view the username and hashed password in the file. We will assign group ownership of the file to apache and then lock down the permissions for everyone else:

$ sudo chown root:apache /var/www/linoxide/passwd.dav
$ sudo chmod 640 /var/www/linoxide/passwd.dav

fixing dav password permission

 4. Configuring Apache Vhost

Now, we'll configure our Apache Web Server's vhost configuration. To do that, we'll need to open the config file using our favorite text editor.

$ sudo nano /etc/httpd/conf/httpd.conf

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/linoxide/webdav/
<Directory /var/www/linoxide/webdav/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
Alias /webdav /var/www/linoxide/webdav/
<Location /webdav>
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/linoxide/passwd.dav
Require valid-user

apache configuration for webdav

Now, after configuring the config file, we'll want to restart our Apache Web Server.

$ sudo systemctl restart httpd.service

restarting httpd service

5. Testing WebDav

To test whether WebDav is properly enabled or not, we'll use a browser and a client to check.

Test using a Web Browser

To test if the authentication is working correctly or not, we'll navigate to our server's IP address or domain name using our favorite web browser.

We'll need to navigate to http://our_IP_address_or_domain/webdav . Then, everything worked fine as illustrated, a prompt for the username and password should appear. Here, we'll need to enter the username and password we set before.

webdav login browser test

Test using a Client

We'll use a WebDav client called cadaver. To install it in our Fedora 21 Server, we'll need to run the following command.

$ sudo yum install cadaver

After installing cadaver, we'll test our webdav using the command below.

$ cadaver http://your_IP_address_or_domain/webdav

If all went well, we'll be asked to enter our username and password we kept before. Then, We should be granted access which means WebDAV is working fine.

Now, we can operate the client and host at the same time using commands that are similar to regular Linux commands. Some of the useful examples are as follows.

To upload

dav:/webdav/> put file

To view/list the contents

dav:/webdav/> ls

To create a new directory and to navigate

dav:/webdav/> mkdir new-dir
dav:/webdav/> cd new-dir

To create files

dav:/webdav/> edit index.html

Now, after done, we can exit using the below command.

dav:/webdav/> exit


Finally, we have successfully set up WebDav with Apache Web Server on our Fedora 21. WebDav is an awesome security module by Apache2 which is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers.  So, if you have any questions, suggestions, feedback please write them in the comment box below. Thank you ! Enjoy  :-)


Share This :

Free Linux Ebook to Download

Comments (1)

Trackback URL | Comments RSS Feed

  1. Pathusz says:

    Hi, I followed your tutorial exactly step by step. Looks like it is working for me but I have one issue with permission. In Cadaver I am getting dav:/webdav/> mkdir testing Creating `testing': failed: 403 Forbidden

    I can't create files. Could you please help me? Thanks

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.