下载解压
到 GitHub 上面下载:https://github.com/filebrowser/filebrowser/releases,根据自己系统等信息下载对应版本。
下载到对应目录后,解压即可,解压后只有一个二进制的文件 filebrowser,可以改名,也可以不改名。后面有些执行需要用到这个,不改名直接用 filebrowser。
配置
虽然官方给的说明是,解压后就可以直接使用。这里还是介绍下一些基本配置。(下面的文件路径根据自己的进行修改,以及一些配置如:端口、用户名密码等)
创建配置文件,并编辑内容:
[html]
# 创建日志文件、配置文件
touch /home/WebFile/WebFile.log
touch /home/WebFile/WebFile.json
# 编辑配置文件,下面代码直接执行即可
cat > /home/WebFile/WebFile.json <<EOF
{
"address": "0.0.0.0",
"port": 10001,
"database": "/home/WebFile/WebFile.db",
"log": "/home/WebFile/WebFile.log",
"locale": "zh-cn",
"username": "ADMIN",
"password": "ADMIN@2022",
"root": "/",
"scope": "/"
}
EOF
[/html]
数据库初始化和配置
[html]
# 创建数据库,并配置,每执行一句,会打印出数据库配置信息,对配置的信息会更新
/home/WebFile/filebrowser -d /home/WebFile/WebFile.db config init
# 设置地址
/home/WebFile/filebrowser -d /home/WebFile/WebFile.db config set --address 0.0.0.0
# 设置端口
/home/WebFile/filebrowser -d /home/WebFile/WebFile.db config set --port 10001
# 设置语言
/home/WebFile/filebrowser -d /home/WebFile/WebFile.db config set --locale zh-cn
# 设置日志文件路径
/home/WebFile/filebrowser -d /home/WebFile/WebFile.db config set --log /home/WebFile/WebFile.log
# 添加用户,并赋管理员权限,设置可查看范围
/home/WebFile/filebrowser -d /home/WebFile/WebFile.db users add zksy zksy@2022 --perm.admin --scope /
[/html]
到这里全部的配置都完成了,启动服务后就可以看到可视化界面。
创新系统管理服务
使用命令行可以直接启动服务(如下命令行)。
[html]
filebrowser -c WebFile.json
[/html]
但是每次启动挺麻烦,下面就把WebFile添加到系统服务,并设置开机自启动。
[html]
# 创建 Systemd 系统管理服务,创建服务文件
cat > /etc/systemd/system/WebFile.service <<EOF
[Unit]
Description=WebFile
Documentation=https://filebrowser.org/
After=network.target
[Service]
ExecStart=/home/WebFile/filebrowser -c /home/WebFile/WebFile.json
[Install]
WantedBy=multi-user.target
EOF
[/html]
有了系统配置文件,第一步要做的就是下面几步:
[html]
# 有了新的服务文件,需要重启 Systemd 服务
systemctl daemon-reload
# 设置开机自启动
systemctl enable WebFile
[/html]
后面就是对服务的一些基本操作:启动、状态、停止等
[html]
# 启动WebFile服务
systemctl start WebFile
# 查看WebFile服务状态
systemctl status WebFile
# 停止WebFile服务
systemctl stop WebFile
# 取消WebFile服务开机自启动
systemctl disable WebFile
[/html]
声明:本文为原创文章,版权归旷野小站所有,欢迎分享本文,转载请保留出处!