Alist搭建

Alist文档

一个支持多种存储,支持网页浏览和 WebDAV 的文件列表程序,由 gin 和 Solidjs 驱动。

安装

手动安装

获取 AList
打开 AList Release 下载待部署系统对应的文件。最新版的前端已经和后端打包好了,不用再下载前端文件了。

xxxx 指的是不同系统/架构对应的名称,一般 Linux-x86/64 为 alist-linux-amd64。如果你的 glibc 版本太低,建议下载 musl 版本

当你看到 start server@0.0.0.0:5244 的输出,之后没有报错,说明操作成功。 第一次运行时会输出初始密码。程序默认监听 5244 端口。 现在打开 http://ip:5244 可以看到登录页面,WebDAV 请参阅 WebDav。

手动运行

1
2
3
4
5
6
7
8
9
# 解压下载的文件,得到可执行文件:
tar -zxvf alist-xxxx.tar.gz
# 授予程序执行权限:
chmod +x alist
# 运行程序
./alist server
# 获得管理员信息
./alist admin

1
2
3
4
5
6
7
8
9
# 解压下载的文件,得到可执行文件:
tar -zxvf alist-xxxx.tar.gz
# 授予程序执行权限:
chmod +x alist
# 运行程序
./alist server
# 获得管理员信息
./alist admin

1
2
3
4
5
6
7
# 解压下载的文件,得到可执行文件:
unzip alist-xxxx.zip
# 运行程序
.\alist.exe server
# 获得管理员信息
.\alist.exe admin

1
2
3
4
5
# 安装
scoop install alist
# 运行
alist server

守护进程

使用任意方式编辑 /usr/lib/systemd/system/alist.service 并添加如下内容,其中 path_alistAList 所在的路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=alist
After=network.target

[Service]
Type=simple
WorkingDirectory=path_alist
ExecStart=path_alist/alist server
Restart=on-failure

[Install]
WantedBy=multi-user.target


然后,执行 systemctl daemon-reload 重载配置,现在你可以使用这些命令来管理程序:

  • 启动: systemctl start alist
  • 关闭: systemctl stop alist
  • 配置开机自启: systemctl enable alist
  • 取消开机自启: systemctl disable alist
  • 状态: systemctl status alist
  • 重启: systemctl restart alist

使用任意方式编辑 ~/Library/LaunchAgents/ci.nn.alist.plist 并添加如下内容,修改 path_alistAList 所在的路径,path/to/working/dirAList的工作路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>ci.nn.alist</string>
<key>KeepAlive</key>
<true/>
<key>ProcessType</key>
<string>Background</string>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>path/to/working/dir</string>
<key>ProgramArguments</key>
<array>
<string>path_alist/alist</string>
<string>server</string>
</array>
</dict>
</plist>


然后,执行 launchctl load ~/Library/LaunchAgents/ci.nn.alist.plist 加载配置,现在你可以使用这些命令来管理程序:

  • 开启: launchctl start ~/Library/LaunchAgents/ci.nn.alist.plist
  • 关闭: launchctl stop ~/Library/LaunchAgents/ci.nn.alist.plist
  • 卸载配置: launchctl unload ~/Library/LaunchAgents/ci.nn.alist.plist
  • 1.https://nssm.cc/download 下载最新版本的 nssm
  • 2. 在解压后的文件夹内按住 Shift 并右击空白处,选择“在此处打开 Powershell 窗口”;
  • 3. 在弹出的窗口中输入 .\nssm.exe install alist
  • 4. Path 选择 alist.exe 的路径,如 D:\alist\alist.exeArgumentsserver
  • 5. Details 选项卡中可以自定义标题和描述,可以选择服务的自启动模式(自动|延迟启动|手动|禁用);
  • 6. 在 I/O 选项卡为 Output (stdout) 和 Output (stderr) 各自指定一个日志文件的路径,如 D:\alist\stdout.log,文件本身(stdout.log)可以不存在,但是指定的目录(D:\alist)必须存在;
  • 7. 点击“Install Service”即可。
    此后可以直接在服务中启动 alist。服务中启动 alist

对于所有平台,您可以使用以下命令来静默启动、停止和重新启动。 (v3.4.0 及更高版本)

1
2
3
4
5
6
# 携带`--force-bin-dir`参数启动服务
alist start
# 通过pid停止服务
alist stop
# 通过pid重启服务
alist restart

使用 Docker 安装

查看管理员信息:

1
docker exec -it alist ./alist admin

docker-cli

1
docker run -d --restart=always -v /etc/alist:/opt/alist/data -p 5244:5244 -e PUID=0 -e PGID=0 -e UMASK=022 --name="alist" xhofe/alist:latest

docker-compose

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '3.3'
services:
alist:
restart: always
volumes:
- '/etc/alist:/opt/alist/data'
ports:
- '5244:5244'
environment:
- PUID=0
- PGID=0
- UMASK=022
container_name: alist
image: 'xhofe/alist:latest'

反向代理

程序默认监听 5244 端口。如有修改,请一并修改下列配置中的端口号。如果你使用反向代理,建议你设置site_url,以帮助alist更好的工作。

nginx

在网站配置文件的 server 字段中添加

1
2
3
4
5
6
7
8
9
10
11
12
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://127.0.0.1:5244;
# the max size of file to upload
client_max_body_size 20000m;
}

如果使用宝塔面板,请务必删除以下默认配置

1
2
3
>- location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md
>- location ~ .\*\.(gif|jpg|jpeg|png|bmp|swf)$
>- location ~ .\*\.(js|css)?$

Apache

VirtualHost 字段下添加配置项 ProxyPass,如:

1
2
3
4
5
6
7
8
<VirtualHost *:80>
ServerName myapp.example.com
ServerAdmin webmaster@example.com
DocumentRoot /www/myapp/public

AllowEncodedSlashes NoDecode
ProxyPass "/" "http://127.0.0.1:5244/" nocanon
</VirtualHost>