Setup WebDAV With Apache2 On ubuntu 9.0.4

by
Share this Article: Facebook0Google+0Twitter0LinkedIn0Reddit0StumbleUpon0

Web-based Distributed Authoring and Versioning, or WebDAV, WebDAV is a protocol that allows for convenient mounting of a remote server on your desktop for easy file access. Once setup, using it is as simple as any other drag and drop navigation on your desktop.

Before to start please change the IP 192.168.1.102 in this tutorial with your own IP.

 

1 Installing WebDAV

If Apache is not already installed, install with:

sudo apt-get install apache2

Afterwards, enable the WebDAV modules:

a2enmod dav_fs
a2enmod dav

Reload Apache:

sudo /etc/init.d/apache2 force-reload


2- Creating A Virtual Host

I will now create a default Apache vhost in the directory /var/www/html/web

First, we create the directory /var/www/html/web and make the Apache user (www-data) the owner of that directory:

sudo mkdir -p /var/www/html/web
sudo  chown www-data /var/www/html/web

make a nackup of the default Apache vhost configuration (/etc/apache2/sites-available/default) and create our own one:

sudo mv /etc/apache2/sites-available/default /etc/apache2/sites-available/default_backup
sudo vi /etc/apache2/sites-available/default
NameVirtualHost *
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/web/
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all

Then reload Apache:

sudo /etc/init.d/apache2 reload


3- Configure Virtual Host For WebDAV

Now we create the WebDAV password file /var/www/web1/passwd.dav with the user user1

sudo htpasswd -c /var/www/html/passwd.dav user1

You will be asked to type in a password for the user user1.

sudo htpasswd /var/www/html/passwd.dav 192.168.1.102user1

(We must use a second backslash here in the user name to escape the first one!)

Now we change the permissions of the /var/www/html/passwd.dav file so that only root and the members of the www-data group can access it:

sudo chown root:www-data /var/www/html/passwd.dav
 sudo chmod 640 /var/www/html/passwd.dav

Now we modify our vhost in /etc/apache2/sites-available/default and add the following lines to it:

sudo vi /etc/apache2/sites-available/default

Now we have to make a Alias /webdav

[...]
Alias /webdav /var/www/html/web
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/html/passwd.dav
Require valid-user
[...]

The final vhost should look like this:

NameVirtualHost *
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/web/
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
Alias /webdav /var/www/html/web
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/html/passwd.dav
Require valid-user

Reload Apache afterwards:

sudo /etc/init.d/apache2 reload


4- Testing WebDAV

We will now install cadaver, a command-line WebDAV client:

sudo apt-get install cadaver

To test if WebDAV works, type:

cadaver http://localhost/webdav/

then inout the login and password

test1.unixmen1:~# cadaver http://localhost/webdav/
 Authentication required for test on server `localhost':
Username: test
Password:
dav:/webdav/> quit
Connection to `localhost' closed.
test1.unixmen:~#

Now go to windows start-run and type ipwebdav or add this directory with add network place .

For any question please; post it in the forum

For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter0LinkedIn0Reddit0StumbleUpon0