How to configure WebDav with Apache on CentOS

WebDAV stands for Web-based Distributed Authoring and Versioning.
It is an extension of the HTTP protocol that allows users to edit and manage documents and files stored on web servers.

Check out the WebDav tutorial for more details

Requirements:

A Linux server with CentOS 6.5

A static IP address

Procedure to setup WebDav Server

Install Apache

# yum install epel-release
# yum update -y
# yum install httpd

Disable Apache’s default page and prevent it from displaying files within the web directory

# sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
# sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start Apache

# service httpd start

Apache loads WebDav modules by default.

The following command can be used to confirm that the modules have been loaded

# httpd -M | grep dav


#  dav_module (shared)
# dav_fs_module (shared)

Create a dedicated directory for WebDav and assign proper permissions and ownership

# mkdir /var/www/html/webdav
# chown -R apache:apache /var/www/html
# chmod -R 755 /var/www/html

Create WebDav user and assign password

#   htpasswd -c /etc/httpd/.htpasswd testuser
Password:

Create a Virtual Host for WebDav and populate with the content below

# vi /etc/httpd/conf.d/webdav.conf


 Alias /webdav /var/www/html/webdav
    <Directory /var/www/html/webdav>
        DAV On
        AuthType Basic
        AuthName "WebDav Authorization Required"
        AuthUserFile /etc/httpd/.htpasswd
        Require valid-user
    </Directory>

Reload Apache
#  service httpd restart

Modify Firewall rules to allow for web traffic

# iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT

# service iptables save
# service iptables restart

Disable SELinux
Use the command below to disable SELinux temporaritly  
# echo 0 > /selinux/enforce
Check how to permanently disable SELinux here

Use Cadaver to test the functionality of the WebDav server
# yum install cadaver
# cadaver http://<your-server-ip>/webdav/

Leave a Reply

Your email address will not be published.