Skip to content

README_APACHE_DAV

OpenLink Software edited this page Nov 17, 2015 · 4 revisions

Installing a DAV repository on Apache

Instructions for Centos 5.x and above

Install Apache

    $ sudo yum install httpd

Enable DAV modules in Apache

All relevant modules are already enabled in a default installation.

Create initial password file for authentication

    $ cd /etc/httpd
    $ sudo htpassword -c webdav.user dav 
    New password: MySecretPassword
    Re-type new password: MySecretPassword
    Added password for user dav

And set the appropriate owner and permissions:

    $ sudo chown root:apache webdav.user
    $ sudo chmod 640 webdav.user

Add extra users

    $ cd /etc/httpd
    $ sudo htpassword webdav.user NewUser

Create the /DAV directory for disk storage

    $ cd /var/www/html
    $ sudo mkdir DAV
    $ sudo chown apache:apache DAV

Install the sample /DAV repository config file

Select the text at the end of this file and paste it into a file called dav.conf and move it to /etc/httpd/conf.d/dav.conf

Restart Apache

    $ sudo /sbin/service httpd restart

Test with browser

Using your favorite browser, click on the sample link to get a directory listing of your /DAV folder.


Instructions for Debian and Ubuntu 12.04 and above

Install Apache

    $ sudo apt-get update
    $ sudo apt-get install apache2 apache2-utils

Enable DAV modules in Apache

    $ sudo a2enmod dav dav_fs headers

Create initial password file for authentication

    $ cd /etc/apache2
    $ sudo htpassword -c webdav.user dav 
    New password: MySecretPassword
    Re-type new password: MySecretPassword
    Added password for user dav

And set the appropriate owner and permissions:

    $ sudo chown root:www-data webdav.user
    $ sudo chmod 640 webdav.user

Add extra users

    $ cd /etc/apache2
    $ sudo htpassword webdav.user NewUser

Create the /DAV directory for disk storage

    $ cd /var/www/html
    $ sudo mkdir DAV
    $ sudo chown www-data DAV

Install the sample /DAV repository config file

Select the text at the end of this file and paste it into a file called dav.conf and move it to /etc/apache2/conf-enabled/dav.conf

Restart Apache

    $ sudo service apache2 restart

Test with browser

Using your favorite browser, click on the sample link to get a directory listing of your /DAV folder.


Sample configuration file for simple /DAV repository

<Location /DAV>
    Order                   Allow,Deny

    #
    #  Enable mod_dav on this location
    #
    Dav                     on
    DavDepthInfinity        on
    
    #
    #  Disable the rewrite engine if it interferes with /DAV repository (optionally uncomment)
    #
    #RewriteEngine           off

    #
    #  Use basic authentication
    #
    AuthType                Basic
    AuthName                WebDAV
    AuthUserFile            webdav.user

    #
    #  Set the DAV tree to be private, so all operations require an authenticated user
    #
    #  To make this DAV repository publicly readable, remove the GET and PROPFIND keywords below
    #
    <Limit GET PROPFIND PROPPATCH PUT POST DELETE MKCOL COPY MOVE LOCK UNLOCK>
        Require         valid-user
    </Limit>

    #
    #  Enable CORS to allow cross-side Ajax scripting
    #
    Header always set Access-Control-Allow-Credentials      true
    Header always set Access-Control-Allow-Origin           "*"
    Header always set Access-Control-Allow-Headers          "authorization, origin, x-requested-with, content-type"
    Header always set Access-Control-Allow-Methods          "PUT, GET, POST, DELETE, OPTIONS, PROPFIND"

</Location>