Creating a WebDav Server in Apache in 600 seconds…

Recently I started doing more web development, and decided instead of developing, my web ideas locally upon my machine, I could create a webdav upon my machine using debian packages, no compiling etc. To create this system, took me about 600 seconds in total. This is the sequence I took to create the webdav system.

Ubuntu:

1. Install apache2 package/software.

# apt-get install apache2

2. Activate the webdav modules within apache2.

# a2enmod dav_fs
# a2enmod dav

Now lets edit your apache default configuration. You can use a different virtualhost if you choose. I choose the default since my development server was upon a vmware instance. I built the instance just for web development work.

3. Go to the default configuration file of your apache2 for to modify for webdav usauge.

# cd /etc/apache2/sites-available

4. Now lets edit the configuration file.

# vi default

5. Edit your configuration file to reflect like mine below.

<VirtualHost *>
ServerAdmin [email protected]
ServerName www.example.com
DocumentRoot /var/www
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/dev_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/machine.log combined
Alias /var/www
<Location /var/www>
DAV On
AuthType basic
AuthName “development”
AuthUserFile /var/www.passwd.dav
Require valid-user
</Location>
</VirtualHost>

Lets explain the parts of the configuration you need to know.

DocumentRoot /var/www

This is the top level directory where your web files reside.

<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

This is the how this directory configuration, change if your need more, I left mine default.

Alias /share /var/www

This line above tells me if I want the call /var/www /dev/ upon my browser or application like dreamweaver etc. e.g. http://www.example.com/share

DocumentRoot /var/www

The about lines sets up the level of security. Since my server is a internal server only, I only used basic security.

<Location /var/www>
DAV On
AuthType Basic
AuthName “development”
AuthUserFile /var/www.passwd.dav
Require valid-user
</Location>

6. Next step is to create the password file that our users and there password is located.

# htpasswd -c /var/www/passwd.dav admin

You need to enter the password for the user, when the above command is entered.

7. We need to change the permissions of the passwd.dav file

# chown root:www-data /var/www/passwd.dav
# chmod 640 /var/www/webdav/passwd.dav

8. Now restart the apache2 webserver application.

# /etc/init.d/apache2 restart

9. Testing the application can be done via the application cadaver. We need to first get the

# apt-get install cadaver