Alpine 系统部署 Sub-Store和 alist 教程
Alpine 系统部署 Sub-Store和 alist 教程 准备工作 安装必要软件包
系统基础配置
创建 sudo 命令软连接
1 doas ln -s $(which doas) /usr/local/bin/sudo
修改 root 密码
配置 SSH 允许 root 登录 在 /etc/ssh/sshd_config.d/50-cloud-init.conf
中添加:
1 2 PasswordAuthentication yes PermitRootLogin yes
调整时区
1 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
更多 Alpine 系统配置可参考:https://linux.do/t/topic/197976
下载安装文件
前端文件:从 Sub-Store-Front-End 下载 dist.zip
后端文件:从 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/substorechmod +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/substorerc-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 服务,可用于备份软件配置,特别适合流量有限的服务器。
下载安装
从 AList Releases 下载 alist-linux-musl-amd64.tar.gz
解压并配置
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 ./alist admin ./alist admin random ./alist admin set 您的新密码
创建服务启动脚本 在 /etc/init.d/
目录下创建名为 alist
的文件:
1 2 touch /etc/init.d/alistchmod +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" command ="/home/alpine/alist/alist" command_args="server" pidfile="/run/${name} .pid" depend () { need net } start_pre () { if [ ! -d "/home/alpine/alist" ]; then eerror "AList 目录不存在!" return 1 fi } start () { ebegin "Starting 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/alistrc-update add alist default rc-service alist start
访问方式 AList 默认监听 5244 端口,可通过以下地址访问:
登录后可在”管理” 中配置 WebDAV 功能。官方文档见
1 https://alist.nn.ci/zh/guide/webdav.html