Thursday, April 7, 2016

Configure webdav on apache2 server as file system provider

webdav (Web Distributed Authoring and Versioning)  is an extension that allows clients to perform remote Web content authoring operations. you can upload, download, rename, change directory of files.

the dav extention of apache2 can provides a framework for users to create, change and move documents on a server.

it can maintenan the properties about author, modification date, namespace management, collections, and overwrite protection, creation, removal, and querying of file information.


*** server, configure as webdav server ***
1- install webdav, usual it come with apache2, you all you need to install is apache2
$ sudo apt-get install apache2

2- enable dav , dav_lock and dav_fs extentions
$ sudo a2enmod dav
$ sudo a2enmod dav_fs
$ sudo a2enmod dav_lock

3- restart apache2 service to make the new configuration take affect
$ sudo service apache2 restart

4- create webdav directory that user can store file and download file
$ mkdir -p /usr/share/apache/dav/davdir

5- create dav.conf in /etc/apache2/conf-enabled/ with the following content
Alias /dav /usr/share/apache/dav/davdir
<Directory "/usr/share/apache/dav/davdir">
    Order allow,deny
    Allow from All
    Require all granted
    Dav On

    AuthType Basic
    AuthName DAV
    AuthUserFile "/etc/user.passwd"
</Directory>



6- create password file /etc/user.passwd and add user: user1 to it
$ sudo htpasswd -c user.passwd user1

7- restart apache2 service
$ sudo service apache2 restart
 -
*** client to access webdav***
++- we can access webdav as mount point or use client to access it.

1- access webdav as mount point
 - installation
$ sudo apt-get install davfs2

 - mount webdav to /mnt
$ mount.davfs http://192.168.202.23:80/dav /mnt
Please enter the username to authenticate with server
http://192.168.202.23:80/dav or hit enter for none.
  Username: user1
Please enter the password to authenticate user user1 with server
http://192.168.202.23:80/dav or hit enter for none.
  Password: 


- now you can copy back and forth, remove file as local file system
$ cp /etc/passwd /mnt/passwd
$  df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                          2.0G  4.0K  2.0G   1% /dev
tmpfs                         394M  1.2M  393M   1% /run
/dev/sda1                     196G   10G  176G   6% /
none                          4.0K     0  4.0K   0% /sys/fs/cgroup
none                          5.0M   12K  5.0M   1% /run/lock
none                          2.0G     0  2.0G   0% /run/shm
none                          100M     0  100M   0% /run/user
http://192.168.202.23:80/dav   26G   13G   13G  50% /mnt


2- use command to upload/download file from webdav
- installation
$ sudo apt-get install davix

- upload file to webdav
$ davix-put --userlogin user1  --userpass password /home/user1/newdoc http://192.168.202.23/dav/newdoc

****note***
if you enable directory list you will be able to see file from you browser as well,
Alias /dav /usr/share/apache/dav/davdir
<Directory "/usr/share/apache/dav/davdir">
   Options Indexes FollowSymLinks MultiViews
    Order allow,deny
    Allow from All
    Require all granted
    Dav On

    AuthType Basic
    AuthName DAV
    AuthUserFile "/etc/user.passwd"
</Directory>


-screenshot

No comments:

Post a Comment