广告

本站里的文章大部分经过自行整理与测试

2017年1月23日星期一

Linux - Lighttpd - WebDAV 服务

1. 准备

$ su

$ mkdir /var/webdav
$ chmod 777 /var/webdav

$ printf "USER:$(openssl passwd -crypt PASSWORD)\n" >> /var/.htpasswd

$ printf "USER:Y/RasqlW9biwY\n" >> /var/.htpasswd


2. 安装

Ubuntu
$ apt install lighttpd lighttpd-mod-webdav
OpenSUSE
$ zypper install lighttpd lighttpd-mod_webdav


3. 设置

Ubuntu
$ gedit /etc/lighttpd/conf-available/10-webdav.conf

server.modules += ( "mod_webdav" )

$HTTP["host"] == "member.dlinkddns.com" {
alias.url = ( "/webdav" => "/var/webdav" )
$HTTP["url"] =~ "^/webdav($|/)" {
server.document-root = "/var/webdav"
dir-listing.activate = "enable"
webdav.activate = "enable"
webdav.is-readonly = "disable"
webdav.sqlite-db-name = "/var/run/lighttpd/lighttpd.webdav_lock.db"
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/var/.htpasswd"
auth.require = ( "" => ( "method" => "basic",
                                               "realm" => "webdav",
                                               "require" => "valid-user" ) )
}
}

OpenSUSE
$ gedit /etc/lighttpd/conf.d/webdav.conf

server.modules += ( "mod_webdav" )

$HTTP["host"] == "member.dlinkddns.com" {
       alias.url = ( "/webdav" => "/var/webdav" )
       $HTTP["url"] =~ "^/webdav($|/)" {
               server.document-root = "/var/webdav"
               dir-listing.activate = "enable"
               webdav.activate = "enable"
               webdav.is-readonly = "disable"
              webdav.sqlite-db-name = home_dir + "/webdav.db"
               auth.backend = "htpasswd"
               auth.backend.htpasswd.userfile = "/var/.htpasswd"
               auth.require = ( "" => ( "method" => "basic",
                                        "realm" => "webdav",
                                        "require" => "valid-user" ) )
       }
}

4. 添加模块

Ubuntu
$ lighty-enable-mod auth
$ lighty-enable-mod webdav

OpenSUSE
$ gedit /etc/lighttpd/lighttpd.conf


server.modules = (
  "mod_access",
  "mod_alias",
  "mod_auth",
..

$ gedit /etc/lighttpd/modules.conf

include "conf.d/webdav.conf"

5. 重新启动

$ systemctl restart lighttpd

6. 防火壁

Ubuntu

$ systemctl start ufw

$ ufw allow 80/tcp
$ ufw allow 443/tcp


7. 客户端

$ apt install davfs2
$ mkdir /media/dav
$ mount -t davfs 
http://member.dlinkddns.com/webdav /media/dav

$ apt install cadaver
$ cadaver 
http://member.dlinkddns.com/webdav

BitKinex
http://www.bitkinex.com/download

WinSCP
https://winscp.net/eng/download.php

没有评论:

发表评论