1.Install compulsory components.
I.Install apache2 server:
sudo apt-get install apache2
II.Enable related modules:
sudo a2enmod dav_fs
sudo a2enmod dav
sudo a2enmod dav_lock
Apache server read the symbolic links in mods-enabled folder to determine which modules to load.So we can create symbolic links to reach the same destination.
You can take ln -s command to make symbolic links of webdav related modules in mods-available folder to mods-enabled folder like this:
sudo ln -s /etc/apache2/mods-available/dav.load /etc/apache2/mods-enabled/dav.load
sudo ln -s /etc/apache2/mods-available/dav_fs.load /etc/apache2/mods-enabled/dav_fs.load
sudo ln -s /etc/apache2/mods-available/dav_lock.load /etc/apache2/mods-enabled/dav_lock.load
sudo ln -s /etc/apache2/mods-available/dav_fs.conf /etc/apache2/mods-enabled/dav_fs.conf
III.Restart apache2 server:
sudo /etc/init.d/apache2 restart
2.Create a virtual host for webdav
mkdir /home/fc/www/webdav
chown fc:fc /home/fc/www/webdav
the first fc is the default user of apache2 server.the second fc is the group of the user.The second fc is used to make the directory accessible to apache2.
3.Create users:
htpasswd -c /home/fc/www/me.dav fc
sudo chown fc:fc /home/fc/www/me.dav
sudo chmod 640 /home/fc/www/me.dav
此处 fc:为用户名,执行此句之后,会提示输入2次密码。以后登陆的时候要用到。
4.Config the virtual host:
sudo cp -a /etc/apache2/sites-available /etc/apache2/sites-available-backup
sudo gedit /etc/apache2/sites-available/default
It obvious that the first line is to backup your default settings.So you can recovery at the least cost when you failed.
Clear the existing codes in gedit and Copy the following into it.[Change the green italic parts in your own case.]
NameVirtualHost *<VirtualHost 172.16.57.67:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/fc/www/webdav
<Directory /home/fc/www/webdav/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /webdav /home/fc/www/webdav
<Location /webdav>
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /home/fc/www/me.dav
Require valid-user
</Location>
</VirtualHost>
5.WebDAV it!
sudo apt-get install cadaver
cadaver http://172.16.57.67/webdav/
Or you can try it on your browser,just type :http:// your ip address/ in the address bar.
Hope you succeed!