https://github.com/filebrowser/filebrowser
https://filebrowser.org/cli/filebrowser
解压
1 2 3 4
| mkdir /opt/local/filebrowser cd /opt/local/ tar -zxvf linux-amd64-filebrowser.tar.gz -C /opt/local/filebrowser/ chmod +x /opt/local/filebrowser/filebrowser
|
添加环境变量
1 2 3 4 5
| echo "export PATH=/opt/local/filebrowser:$PATH" >> /etc/profile #vim /etc/profile #export PATH=$PATH:/opt/local/mysql/bin # 使环境变量生效 source /etc/profile
|
创建配置文件
vim /opt/local/filebrowser/config.json
:
1 2 3 4
| { "database":"/opt/local/filebrowser/filebrowser.db", "log":"/opt/local/filebrowser/filebrowser.log" }
|
配置初始化和修改
这里不建议指定 --scope upload
和 --perm.admin
选项,因为会作为新增用户的默认配置。
1 2 3 4 5 6
| # filebrowser config init [flags] filebrowser -c /opt/local/filebrowser/config.json config init --address 0.0.0.0 --port 8999 --locale zh-cn
# filebrowser config set [flags] # --root 拼接 --scope 作为默认的用户路径 filebrowser -c /opt/local/filebrowser/config.json config set --root /opt/local/filebrowser --scope /common
|
查看配置
1 2
| # filebrowser config cat [flags] filebrowser -c /opt/local/filebrowser/config.json config cat
|
查看用户
1 2
| # filebrowser users ls [flags] filebrowser -c /opt/local/filebrowser/config.json users ls
|
添加用户
覆盖上文 --scope
选项。
1 2 3
| # filebrowser users add <username> <password> [flags] filebrowser -c /opt/local/filebrowser/config.json users add admin admin --perm.admin --scope /admin filebrowser -c /opt/local/filebrowser/config.json users add zhaolq zhaolq --scope /zhaolq
|
启动
1 2 3
| filebrowser --config /opt/local/filebrowser/config.json # 或 filebrowser -c /opt/local/filebrowser/config.json
|
开机自启
vim /etc/systemd/system/filebrowser.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [Unit] Description=File Browser After=network.target
[Service] # Type=forking 会导致 systemctl start service 阻塞 Type=simple User=root Group=root ExecStart=/opt/local/filebrowser/filebrowser --config /opt/local/filebrowser/config.json Restart=on-failure
[Install] WantedBy=multi-user.target
|
systemctl
管理
1 2 3 4
| systemctl daemon-reload systemctl start filebrowser systemctl stop filebrowser systemctl enable filebrowser
|