Create WebDAV share in Centos using Apache

The following instructions detail how to setup a WebDAV share. I am creating the share in /webdav/company that will be accessable from http://webdrive.onemetric.com.au/

  1. Install Apache
    [root@web1 ~]# yum install httpd
    
  2. Now Create the appropriate directories and set the permissions
    [root@web1 ~]# mkdir /webdav
    [root@web1 ~]# mkdir /webdav/shares
    [root@web1 ~]# chown apache:apache /webdav/company/
    [root@web1 ~]# chown apache:apache /webdav/
    
  3. Now edit the Apache httpd.conf file
    [root@web1 ~]# vim /etc/httpd/conf/httpd.conf
    

    At the very bottom of the file you need to configure a new Virtual Host that will act as the WebDav share

    <VirtualHost webdrive.onemetric.com.au:80>
    
            ServerAdmin peter@onemetric.com.au
            DocumentRoot /webdav/company/
            ServerName webdrive.onemetric.com.au
    
            <Directory />
                    Dav On
                    AuthType Digest
                    AuthUserFile /webdav/.auth
                    AuthName OneMetric
                    require valid-user
            </Directory>
    </VirtualHost>
    

    The main lines to note are:

    • < VirtualHost webdrive.onemetric.com.au:80 > – specifies the hostname and port that the drive will be available on
    • DocumentRoot – specifies the directory that will be available over WebDav
    • ServerName – the hsotname that the drive will be available from
    • AuthUserFile – the auth file used to authenticate users from
    • AuthName – the realm to authenticate against
  4. You now need to create users to authenticate with
    [root@web1 ~]# htdigest -c /webdav/.auth OneMetric peter
    

    Note the realm specified by the AuthName comes before the username and it is case sensitive. You will then be asked for the password twice and the user will be created

  5. Now set Apache to start and run on boot
    [root@web1 ~]# /etc/init.d/httpd start
    [root@web1 ~]# chkconfig httpd on
    
  6. You should now be able to map access the WebDAV drive