Red Hat / CentOS Linux: Apache Enable WebDAV

Q. Web-based Distributed Authoring and Versioning ( WebDAV) – is a set of extensions to the Hypertext Transfer Protocol (HTTP) that allows users to collaboratively edit and manage files on remote World Wide Web servers. How do I enable WebDAV under CentOS / RHEL 5 Linux server?

A. WebDAV can be easily created under httpd. All you have to do is add following directive alias.

httpd Dav on

Open httpd.conf file:
# vi httpd.conf
Append following directive:

Alias /webdav /home/httpd/webdav
Dav on

Save and close the file. Update: here is my sample /etc/httpd/conf.d/webdav.conf file. Instead of putting above two lines in httpd.conf, create /etc/httpd/conf.d/webdav.conf as follows:

 <IfModule mod_dav.c>
    LimitXMLRequestBody 131072
 
    Alias /webdav "/home/httpd/webdav"
    <Directory /home/httpd/webdav>
        Dav On
        Options +Indexes
        IndexOptions FancyIndexing
        AddDefaultCharset UTF-8
        AuthType Basic
        AuthName "WebDAV Server"
        AuthUserFile /etc/httpd/webdav.users.pwd
        Require valid-user
        Order allow,deny
        Allow from all
    </Directory>
 </IfModule>

The configuration file will automatically be included. Run following to create user and password for user called tom:
# htpasswd -c /etc/httpd/webdav.users.pwd tom
You need to enter a password. The -c option creates the /etc/httpd/webdav.users.pwd. It can be left out when others users are added to the database. Now, create /home/httpd/webdav and set ownership:
# mkdir -p /home/httpd/webdav
# chown apache:apache /home/httpd/webdav

Finally, restart apache, enter:
# /etc/init.d/httpd restart

How do I access WebDAV in Windows / Linux / UNIX and Mac OS X?

Windows XP / 2003 server or higher have WebDAV client. Open My network places and click Add network place. Enter the WebDAV URL (e.g. http://yourdomain.com/webdav).

WebDAV in OS X

Click Finder > From the Finder menu, select Go > Connect to Server.

Type in the URL (e.g. http://yourdomain.com/webdav), and press the + button to save it as a favourite. Finally, provide username and password.

WebDAV in Linux / UNIX

Use GUI file manager.

KDE supports WebDAV by just using URLs that start with webdav:// or webdavs://. For e.g, open konqueror and type the url webdav://yourdomain.com/webdav

The Gnome file browser Nautilus also has WebDAV support in recent versions, using normal URLs with http://. Open Nautilus and type the url http://yourdomain.com/webdav.

Command-line WebDAV client for Unix / Linux

Use cadaver client, it supports file upload, download, on-screen display, namespace operations (move and copy), collection creation and deletion, and locking operations. Its operation is similar to the standard ftp client and the Samba Project’s smbclient. A user familiar with these tools should be quite comfortable with cadaver. cadaver supports automatically logging in to servers requiring authentication via a .netrc file (similar to ftp).

To onnect to webdav server, from a shell prompt enter:
$ cadaver http://your-server.com/webdav

References:

  • webdav
  • man page httpd.conf and cadaver
🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
18 comments… add one
  • Manoj Dec 3, 2008 @ 12:41

    getting error while restarting my apache
    [root@testbox ~]# /etc/init.d/httpd restart
    Stopping httpd: [FAILED]
    Starting httpd: Syntax error on line 555 of /etc/httpd/conf/httpd.conf:
    DAV not allowed here
    [FAILED]
    [root@testbox ~]#

  • Manoj Dec 3, 2008 @ 12:45

    menting “Dav on” under would work

    ———–
    Alias /webdav /home/httpd/webdav

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    Dav on

    =======================

  • Jason Dec 3, 2008 @ 19:04

    I think this article is missing something and the comments tried to clean it up, but they too didn’t work on my CentOS system. Put the following in a file /etc/httpd/conf.d/webdav.conf and then reload httpd.

    Alias /webdav /home/httpd/webdav/

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    Dav on

  • Jason Dec 3, 2008 @ 19:05

    How do we provide for authentication? Do you recommend just using an .htaccess file?

  • 🐧 nixCraft Dec 3, 2008 @ 19:17

    @Manoj / Jason,

    The faq has been updated to fix the problem. Let me know if you need anything else.

  • Jason Dec 3, 2008 @ 19:36

    Thanks for the update. Your website has been so helpful. One more tip: if you’re doing WebDAV over the Internet and using authentication (which you should) be sure to enable HTTPS to protect those passwords.

  • John Paul Dec 29, 2008 @ 14:30

    Hi

    I am wondering if this is possible;

    read only for everyone, and only write access for people allowed to modify the site.

    im in the process of rebuilding a website and will be using Adobe Contribute for 3 staff to update the site, but it will need to be publically viewable, but only writable by 3 staff, is this easy to acomplish?

  • akuba Mar 13, 2009 @ 15:06

    thanks!

  • Amsterdam Aug 3, 2009 @ 1:32

    Hi, Im on a BlueOnyx box (CentOS 5.3).
    I used the updated part, not the example above it.
    My Apache httpd.conf already had WebDAV, which I left untouched:

    # Location of the WebDAV lock database.
    DAVLockDB /var/lib/dav/lockdb

    I have user includes, for user specific httpd config. There, I added your example. And I changed to my . Works like a charm. Connected on my OS-X desktop. And on the interwebs it asked for authentication. Thanks for the example here.

  • Amsterdam Aug 3, 2009 @ 1:36

    Sorry for my broken post. That isnt really a userfriendly interface here.. ;-)

  • niels Aug 4, 2009 @ 16:40

    Hi,

    I have an Centos 5.3 Server running
    But it won’t work. When i try to connect i’am getting the message :
    Could not acces /webdav/ 405 Method Not Allowed
    Connection to ‘localhost’ closed..

    Can you help me?

  • Amsterdam Aug 6, 2009 @ 21:59

    Niels, that is what I’m experiencing at my live BX box too. However, it works perfect in my localhost testing box at home. Both are BX CentOS5.3. The example above works. Im a rookie, Im figuring out my next move.

  • Amsterdam Aug 12, 2009 @ 18:15

    Test interface before I answer..
    <dude/"web">
    citing

  • Amsterdam Aug 12, 2009 @ 18:25

    Okay, here is what I did on my CentOS 5.3 BlueOnyx box..
    In /etc/httpd/conf/httpd.conf , I have the following:
    If you don’t have dav_fs module I guess you’ll simply use mod_dav.c..

    <IfModule mod_dav_fs.c>
    DAVLockDB /var/lib/dav/lockdb
    DAVDepthInfinity On
    DAVMinTimeout 600
    </IfModule>

    I make a my directory webdav (in root, not in /web).
    I add my user-login to a pwd file.

    mkdir /home/sites/your.domain.tld/webdav (give it rights)
    htpasswd -c /etc/httpd/your.webdav.users.pwd yourname

    For my sites, BX takes care of loading configs for vhosts.
    So, for vhost #14 I have the following for /etc/httpd/conf/vhosts/site14.include

    <Directory /home/sites/your.domain.tld/web>
    Options Indexes FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
    </Directory>

    <IfModule mod_dav_fs.c>

    LimitXMLRequestBody 131072

    <Directory /home/sites/your.domain.tld/webdav>
    # Options none
    Options Indexes FollowSymLinks
    IndexOptions FancyIndexing
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    Alias /webdav "/home/sites/your.domain.tld/webdav"

    <Location /webdav>
    DAV On
    AuthType Basic
    AuthName DAV
    AuthUserFile /etc/httpd/your.webdav.users.pwd
    <LimitExcept GET HEAD OPTIONS>
    require user yourname
    </LimitExcept>
    </Location>
    </IfModule>

    This way, you can make seperate settings, like if you want browser web-access. If not, you can uncomment the commented Options None, and comment the current Options and IndexOptions. Alike you can change access by chaging the Limit or LimitExept.

    Keep in touch with the dutch.
    regards, Frank

  • luigi Sep 1, 2010 @ 22:47

    Hi, a few months ago, i configure my apache server to allow web dav calendar sharing.
    im using outlook 2007 as a cliente, and now people who share their calendar, has loss all the appointments and task, olders than three monts.
    If someone know how this could happend, i really appreciate your help.
    Thanks.

  • Richard Jan 14, 2011 @ 13:16

    Thank you very much! Worked like a charm on my Centos virtual machine. I use no-ip.org dyndns to forward to the centos VM and can now easily access, transfer (up and download) and edit files on my iPad from anywhere. The free iPad App Webdav Nav works excellent in this combination!

  • Kai May 16, 2012 @ 13:25

    SSL?

  • n0rbertt Feb 3, 2013 @ 20:13

    You don’t need:

    Order allow,deny
    Allow from all

    if you have:
    Require valid-user

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.