Linux部署Filebrowser

发表于
21

1、下载:

从Github下载:https://github.com/filebrowser/filebrowser

在Releases里面,按照系统和处理器架构下载最新版本,此处下载了

linux-arm64-filebrowser.tar.gz

大约7MB

可选:在Windows上下载好,通过scp传到服务器

2、解压缩:

tar -zxvf linux-arm64-filebrowser.tar.gz

此时会得到:filebrowser可执行文件、LICENSE、README.md等文件

只需要filebrowser可执行文件

3、安装和配置:

将filebrowser可执行文件移动到软件目录,比如/usr/local/bin/下面

然后就可以直接在终端用命令filebrowser了

(1)配置步骤

初始化内置数据库文件filebrowser.db,它会在当前目录下生成一个数据库文件filebrowser.db

filebrowser -d filebrowser.db config init

设置管理员用户名和密码(用户名:kkk,密码:123456,可以自己修改)

filebrowser -d filebrowser.db users add kkk 123456 --perm.admin

设置访问地址为0.0.0.0(这个不能变),这样就能在外网或者192.168.x.x(你的内网地址)访问了。注意,默认的127.0.0.1有时不能访问,改成这个就好了。

filebrowser -d filebrowser.db config set --address 0.0.0.0

修改访问端口号为1234, 就能用192.168.x.x:1234来访问了

filebrowser -d filebrowser.db config set --port 1234

设置根目录为电脑的d盘,根据自己需要改。

filebrowser -d filebrowser.db config set --root /

(2)正式运行程序:

filebrowser.exe -d ./filebrowser.db --disable-preview-resize --disable-type-detection-by-header --cache-dir ./cache

这几个参数的说明:./表示当前目录。

-d .\filebrowser.db 表示数据库文件是当前目录的filebrowser.db

--disable-preview-resize 表示禁止压缩图片,低端服务器最好关上,不然会很卡很卡。普通服务器也最好关上,会生成好多压缩后的图片文件,也就在访问时省一点流量。如果嫌原图片太大,可以自己提前用windows系统的图片批量压缩工具处理一下,比访问时让服务器压缩要好。

--disable-type-detection-by-header 这个一定要关,加快列表显示速度的,5000个文件的文件夹只要2秒就能显示出来,如果不关,要30秒。不知道为啥不把它设为默认关闭。好多人不知道设这个。

--cache-dir ./cache 设置缓存文件夹为当前目录的cache文件夹(没有的话自己会建一个),最好加这个,放置图片缩略图的,第二次访问同目录时,图片缩略图显示会快很多。

然后就能用电脑或手机浏览器访问:

192.168.x.x:1234,

或你外网的url:1234

完整的运行命令:

/usr/local/bin/filebrowser -d /opt/filebrowser/filebrowser.db --disable-preview-resize --disable-type-detection-by-header --cache-dir /tmp/filebrowser/cache

可以添加systemd进程:

Vim /etc/systemd/system/filebrowser.service

写以下配置:

[Unit]
Description=Filebrowser
After=network-online.target

[Service]
User=root
Group=root
Type=simple
Restart=always
ExecStart=/usr/local/bin/filebrowser -d /usr/local/filebrowser/filebrowser.db --disable-preview-resize --disable-type-detection-by-header --cache-dir /tmp/filebrowser/cache

[Install]
WantedBy=multi-user.target

保存后,运行

systemctl enable filebrowser

systemctl start filebrowser

systemctl status filebrowser

看到active就可以访问了

也可以在配置目录新建filebrowser.service编辑好,然后建软链,再enable

ln -s /usr/local/filebrowser/filebrowser.service /etc/systemd/system/filebrowser.service

systemctl daemon-reload