之前介绍过Nginx模块实现是Webdav 这次介绍一个由Go语言编写的WebDav服务端搭建过程,个人感觉比其他众方式都简单实用,单文件可执行,不需要额外配置。
服务器选用腾讯云香港轻量,回国线路优秀,30M带宽足够使用,部署好Webdav,挂载在手机上不要太爽。
轻量应用服务器无忧计划_轻量应用服务器续费同价-腾讯云 (tencent.com)
轻量应用服务器无忧计划_轻量应用服务器续费同价-腾讯云 (tencent.com)
正文:
首先放上本次的主角,github链接如下
https://github.com/hacdias/webdav
它支持各个系统及平台,windows端部署也是大同小异,毕竟只需要一个可执行文件以及一个配置文件即可
首先先建立一个运行目录,并下载服务端
mkdir /home/webdav
#尽量不在root目录,以避免权限问题
wget https://github.com/hacdias/webdav/releases/download/v4.1.0/linux-amd64-webdav.tar.gz
tar -xzvf linux-amd64-webdav.tar.gz
#解压文件
然后新建下配置文件,配置文件支持yaml json toml等配置文件,注意编码一定要为utf-8
使用vi vim nano等文本编辑工具编辑config.yaml粘贴以下内容,并修改相应的内容
# Server related settings
address: 0.0.0.0
port: 51234
auth: true
tls: false
cert: cert.pem
key: key.pem# Default user settings (will be merged)
scope: .
modify: true
rules: []users:
– username: user1
password: user1
scope: /home/webdav
– username: user2
password: user2
scope: /home/webdav
同时密码支持bcrypt加密具体看github说明去,这里提供一个在线生成bcrypt加密的地址https://bcrypt-generator.com/
好的,现在你可以尝试使用以下命令开启你的服务端了
webdav –config config.yaml
使用vi vim nano等编辑器编辑 /lib/systemd/system/webdav.service文件写入以下内容
[Unit]
Description=WebDAV server
After=network.target[Service]
Type=simple
User=root
ExecStart=/home/webdav/webdav –config /home/webdav/config.yaml
Restart=on-failure[Install]
WantedBy=multi-user.target
systemctl start webdav
#启动webdav
systemctl enable webdav
#设置开机启动
好了,使用你的客户端尝试连接即可!
电脑端可以使用raidrive 手机端推荐ES文件浏览器,觉得存储空间不够的可以再去购买OSS进行挂载。
原文地址:https://hostloc.com/thread-890281-1-1.html