Linux: Setup and Enable WebDAV in Apache

WebDAV is Web-based Distributed Authoring and Versioning. In my environment, we have many web developer and programmers working on the same site, with access to some particular folder in the web development server. There are a lot of way that we can used to manage remote file and doing web publishing in the same time like FTP, SFTP, FrontPage, Samba and many other sharing protocol.

The best thing about WebDAV is it allow for file locking if someone is editing the file. It is suitable with my environment and I need to deliver this via our web server (Apache). Variables as below:

OS: CentOS 5.6 64bit
Web server: Apache 2.2.3
Web root: /home/webtest/public_html
WebDAV user1: mike
WebDAV password: mikecute
WebDAV user2: doni
WebDAV password: donifast

1. Lets start by installing Apache via yum:

$ yum install httpd* -y

2. Since we might need to have PHP and MySQL running as well, we need to install them accordingly:

$ yum install php53* mysql* -y

3. Enable MySQL and Apache in startup:

$ chkconfig httpd on
$ chkconfig mysqld on

4. Since this is a test server which only being access locally and we already have in-house firewall system, I am going to disable iptables and SElinux in this server:

$ iptables -F
$ service iptables stop
$ chkconfig iptables off
$ setenforce 0

5. Since Apache has installed WebDAV module by default, lets create virtual host and enable WebDAV for the test environment as variables above. Open /etc/httpd/conf/httpd.conf via text editor and add following line at the end of the file:

NameVirtualHost *:80
 
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /home/webtest/public_html
    ServerName webtest.com
    ErrorLog logs/webtest.com-error_log
    CustomLog logs/webtest.com-access_log common
        Alias /webdav /home/webtest/public_html
        <Location /webdav>
           DAV On
           AuthType Digest
           AuthName "WebDAV_Authentication"
           AuthUserFile  /home/webtest/digest-password
           Require valid-user
       </Location>
 
</VirtualHost>
DAVLockDB /tmp/DAVLock
DAVMinTimeout 600

6. We need to restart Apache for this:

$ service httpd restart

7. Now, lets create the WebDAV user. If you see on the configuration on step 5, we will use digest access authentication. So we need to use htdigest command. If you want to use basic authentication, please use htpassword command and change the ‘Digest’ value in httpd.conf to ‘Basic’. It is recommended to use digest, lets create user Mike:

$ htdigest -c /home/webtest/digest-password WebDAV_Authentication mike
Adding password for mike in realm WebDAV_Authentication.
New password:
Re-type new password:

8. Add another user for Doni:

$ htdigest /home/webtest/digest-password WebDAV_Authentication doni
Adding password for doni in realm WebDAV_Authentication.
New password:
Re-type new password:

9. We should see something like below in the user database file after adding 2 users:

$ cat /home/ipmart/digest-password
mike:WebDAV_Authentication:6f8b04a18c6ca16ac287182e19fead75
doni:WebDAV_Authentication:a633d504aad14b08ad38c7cd846c5edc

Done! Lets ask the client to access. If client run in Windows 7, simply use My Computer on Map Network Drive utilities, or you can use any WebDAV client like Dreamweaver, BitKinex, CrossFTP, CyberDuck or NetDrive. For Linux command line, we can use cadaver which available via yum.

By the way, the WebDAV URL for this setup is http://192.168.0.100/webdav

Leave a comment

Leave a Reply

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