Alpine 系统部署 Sub-Store和 alist 教程

Alpine 系统部署 Sub-Store和 alist 教程

gaoyanchen Lv3

Alpine 系统部署 Sub-Store和 alist 教程

准备工作

安装必要软件包

1
sudo apk add node

系统基础配置

  1. 创建 sudo 命令软连接
1
doas ln -s $(which doas) /usr/local/bin/sudo
  1. 修改 root 密码
1
sudo passwd root
  1. 配置 SSH 允许 root 登录
    /etc/ssh/sshd_config.d/50-cloud-init.conf 中添加:
1
2
PasswordAuthentication yes
PermitRootLogin yes
  1. 调整时区
1
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

更多 Alpine 系统配置可参考:https://linux.do/t/topic/197976

下载安装文件

  1. 前端文件:从 Sub-Store-Front-End 下载 dist.zip
  2. 后端文件:从 Sub-Store 下载 sub-store.min.js

部署步骤

目录结构

1
2
3
/root/sub-store/
├── frontend/dist/ # 前端文件解压到此
└── sub-store.bundle.js # 后端文件

创建服务启动脚本

/etc/init.d/ 目录下创建名为 substore 的文件:

1
2
touch /etc/init.d/substore
chmod +x /etc/init.d/substore

编辑内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/sbin/openrc-run

name="Sub-Store"
description="Sub-Store Backend Service"
command="/usr/bin/node"
command_args="/root/sub-store/sub-store.bundle.js"
command_user="root"
pidfile="/var/run/sub-store.pid"

# 环境变量配置
export SUB_STORE_FRONTEND_BACKEND_PATH="/2cXaAxRGfddmGz2yx1wA"
export SUB_STORE_BACKEND_CRON="0 0 * * *"
# 你自己的目录
export SUB_STORE_FRONTEND_PATH="/root/sub-store/frontend/dist"
export SUB_STORE_FRONTEND_HOST="0.0.0.0"
export SUB_STORE_FRONTEND_PORT="3001"
# 你自己的目录
export SUB_STORE_DATA_BASE_PATH="/root/sub-store"
export SUB_STORE_BACKEND_API_HOST="127.0.0.1"
export SUB_STORE_BACKEND_API_PORT="3000"

depend() {
need net
after firewall
}

start_pre() {
# 资源限制配置
ulimit -n 32767
echo "[$(date)] 启动检测:Node版本 $(node -v)" > /var/log/sub-store.log
}

start() {
ebegin "Starting Sub-Store"
start-stop-daemon --start \
--user "$command_user" \
--exec "$command" \
--pidfile "$pidfile" \
--make-pidfile \
--background \
-- \
$command_args >> /var/log/sub-store.log 2>&1
eend $?
}

stop() {
ebegin "Stopping Sub-Store"
start-stop-daemon --stop \
--pidfile "$pidfile" \
--exec "$command"
eend $?
rm -f "$pidfile"
}

安全提示:请将 SUB_STORE_FRONTEND_BACKEND_PATH 的值 /2cXaAxRGfddmGz2yx1wA 修改为其他复杂字符串,这是 API 验证所必需的。不要更改后端 API 监听地址,保持 SUB_STORE_BACKEND_API_HOST=127.0.0.1 ,尤其是监听的3000端口不要开公网,可避免 API 暴露在公网。

启动服务

1
2
3
chmod +x /etc/init.d/substore
rc-update add substore default # 加入开机启动
rc-service substore start # 立即启动服务

访问方式

直接 IP 访问

1
http://服务器IP:3001?api=http://服务器IP:3001/路径标识符

说明:将”服务器IP”替换为您的实际IP地址,”路径标识符”替换为您在配置文件中设置的 SUB_STORE_FRONTEND_BACKEND_PATH 值(默认为 2cXaAxRGfddmGz2yx1wA)。

配置域名和 SSL

如需使用域名并配置 SSL,可参考:https://surge.tel/08/2930/


AList 部署教程

主要用AList 提供的WebDAV 服务,可用于备份软件配置,特别适合流量有限的服务器。

下载安装

  1. AList Releases 下载 alist-linux-musl-amd64.tar.gz
  2. 解压并配置
1
2
3
4
5
6
7
8
# 解压下载的文件
tar -zxvf alist-linux-musl-amd64.tar.gz

# 授予程序执行权限
chmod +x alist

# 测试运行程序
./alist server

管理员配置

修改管理员密码

1
2
3
4
5
6
7
8
# v3.25.0 以下版本
./alist admin

# v3.25.0 及以上版本
# 随机生成密码
./alist admin random
# 或设置自定义密码
./alist admin set 您的新密码

创建服务启动脚本

/etc/init.d/ 目录下创建名为 alist 的文件:

1
2
touch /etc/init.d/alist
chmod +x /etc/init.d/alist

编辑内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/sbin/openrc-run

name="alist"
description="AList WebDAV Service"
# 替换为您的 AList 安装目录
command="/home/alpine/alist/alist"
command_args="server"
pidfile="/run/${name}.pid"

depend() {
need net
}

start_pre() {
# 替换为您的 AList 安装目录
if [ ! -d "/home/alpine/alist" ]; then
eerror "AList 目录不存在!"
return 1
fi
}

start() {
ebegin "Starting AList"
# 替换为您的 AList 安装目录
cd "/home/alpine/alist" && nohup ./alist server > /var/log/alist.log 2>&1 &
echo $! > ${pidfile}
eend $?
}

stop() {
ebegin "Stopping AList"
start-stop-daemon --stop --pidfile "$pidfile"
eend $?
rm -f "$pidfile"
}

注意:请将脚本中的 /home/alpine/alist 路径替换为您实际的 AList 安装目录

启动服务

1
2
3
chmod +x /etc/init.d/alist
rc-update add alist default # 加入开机启动
rc-service alist start # 立即启动服务

访问方式

AList 默认监听 5244 端口,可通过以下地址访问:

1
http://服务器IP:5244

登录后可在”管理” 中配置 WebDAV 功能。官方文档见

1
https://alist.nn.ci/zh/guide/webdav.html
  • Title: Alpine 系统部署 Sub-Store和 alist 教程
  • Author: gaoyanchen
  • Created at : 2025-04-11 19:07:05
  • Updated at : 2025-04-18 15:26:21
  • Link: https://gyc.660624.xyz/2025/04/11/Alpine 系统部署 Sub-Store和 alist 教程/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments