2025/07/30

自建Sub-Store节点管理bash 复制 下载 apt update -y #Debian 命令

VPS服务器选择:  原生IP注册  ,  高速IP购买  ,  指纹浏览器 , 中转加速降低延迟 , 泰国高速VPS , 东南亚VPS推荐 

项目地址

前端:GitHub 地址

后端:GitHub 地址

Sub-Store 服务搭建(一)

以下是没有宝塔面板的搭建方式,若是有宝塔面板,会方便很多

更新系统

apt update -y   #Debian 命令

安装所需组件

apt install unzip curl wget git sudo -y   #Debian 命令

安装 FNM 版本管理器

curl -fsSL https://fnm.vercel.app/install | bash

按照回显的图示,运行命令保存生效

source /root/.bashrc  #请按照你的回显提示命令进行输入,我这边路径是 /root

FNM 安装 Node

fnm install v20.18.0
node -v  # 回显返回版本号即为安装成功

安装 PNPM 软件包管理器

curl -fsSL https://get.pnpm.io/install.sh | sh -

按照回显的图示,运行命令

source /root/.bashrc

安装 Sub-Store

创建文件夹并拉取项目

mkdir -p /root/sub-store  #在 root 目录下面创建 sub-store 文件夹
cd sub-store   #进入 sub-store 文件夹

拉取项目并解压

# 拉取后端项目
curl -fsSL https://github.com/sub-store-org/Sub-Store/releases/latest/download/sub-store.bundle.js -o sub-store.bundle.js
 
# 拉取前端项目
curl -fsSL https://github.com/sub-store-org/Sub-Store-Front-End/releases/latest/download/dist.zip -o dist.zip

解压前端文件,并改名为 frontend,而后删除源压缩文件

unzip dist.zip && mv dist frontend && rm dist.zip

创建系统服务

pm2 的启动方式会有 BUG,所以我们采用服务进程的方式来启动

进入 VPS 目录 /etc/systemd/system/,在里面创建一个文件 sub-store.service,写入以下服务信息

[Unit]
Description=Sub-Store
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
 
[Service]
LimitNOFILE=32767
Type=simple
Environment="SUB_STORE_FRONTEND_BACKEND_PATH=/9GgGyhWFEguXZBT3oHPY"
Environment="SUB_STORE_BACKEND_CRON=0 0 * * *"
Environment="SUB_STORE_FRONTEND_PATH=/root/sub-store/frontend"
Environment="SUB_STORE_FRONTEND_HOST=0.0.0.0"
Environment="SUB_STORE_FRONTEND_PORT=3001"
Environment="SUB_STORE_DATA_BASE_PATH=/root/sub-store"
Environment="SUB_STORE_BACKEND_API_HOST=127.0.0.1"
Environment="SUB_STORE_BACKEND_API_PORT=3000"
ExecStart=/root/.local/share/fnm/fnm exec --using v20.18.0 node /root/sub-store/sub-store.bundle.js
User=root
Group=root
Restart=on-failure
RestartSec=5s
ExecStartPre=/bin/sh -c ulimit -n 51200
StandardOutput=journal
StandardError=journal
 
[Install]
WantedBy=multi-user.target

上面服务代码中的 9GgGyhWFEguXZBT3oHPY 为API请求密钥,请自行修改,推荐自动生成地址:点击访问

后端服务相关命令

systemctl start sub-store.service     #启动服务
systemctl enable sub-store.service    #设置为开机自启
systemctl status sub-store.service    #查看服务状态
systemctl stop sub-store.service      #停止服务
systemctl restart sub-store.service   #重启服务

正常情况下,运行服务状态,应该类似下图:( active:running

若是出现错误,你也是可以通过下面的命令来查看日志,来排除相关的错误

# 个命令用于实时查看 sub-store 服务的最新 100 行日志,并继续跟踪后续的日志输出。
journalctl -f -u sub-store -o cat -n 100

至此,sub-store 服务搭建完毕,若是不想绑定域名,你目前可以通过如下的IP+API的方式进行请求(当然,还是强烈的建议使用域名,并开启 CDN 的小云朵,用于隐藏真实 IP)

若是确定不使用域名,到这里就结束了。以下的内容可以不用再看!

# 9GgGyhWFEguXZBT3oHPY 为你的 API 请求密钥
 
http://IP:3001/?api=http://IP:3001/9GgGyhWFEguXZBT3oHPY

解析域名申请证书

我们解析域名,类型 A ,名称:随意 ,内容:VPS IP ,代理状态:开启,TTL:自动

然后,如下图所示,我们创建一个免费,有效期为 15 年的证书

记录自己的 证书 以及 密钥文件!

证书文件保存为 /root/cert/ssl.pem (方便接下来的 Nginx 的配置,不建议改名字)

密钥文件保存为 /root/cert/ssl.key

安装配置 Nginx

安装 Nginx 服务

apt install nginx -y

访问 http://VPSIP,可以到达 Nginx 的欢迎页面,证明 Nginx 安装成功

来到 VPS 的 Nginx 配置目录:/etc/nginx/sites-enabled/

在文件夹下面创建 sub-store.conf 文件,而后写入如下反代配置:

注意:需要修改 sub.myss.us 为你自己刚才解析的域名

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name sub.myss.us;
 
  ssl_certificate /root/cert/ssl.pem;
  ssl_certificate_key /root/cert/ssl.key;
 
  location / {
    proxy_pass http://127.0.0.1:3001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
 
}

确认无误以后,保存,并使用如下命令生效:

nginx -s reload   # 重载Nginx配置
 
nginx -t          # 查看配置是否正确

重载 Nginx 服务,若是不报错,Nginx 反代成功,目前可以访问如下网址(自行替换域名)到达订阅页面

https://sub.myss.us/?api=https://sub.myss.us/9GgGyhWFEguXZBT3oHPY

Sub-Store 服务更新

systemctl stop sub-store.service  # 停止服务
cd sub-store            # 进入 sub-store 文件夹
# 更新项目脚本
curl -fsSL https://github.com/sub-store-org/Sub-Store/releases/latest/download/sub-store.bundle.js -o sub-store.bundle.js
systemctl daemon-reload      # 重载服务
systemctl start sub-store.service  # 启动服务
systemctl status sub-store.service  # 查看服务状态

具体的Sub-Store的使用方法,可以查看这期视频

Sub-Store 服务搭建(二)

以下是宝塔面板的搭建方式,会方便很多

安装Node管理器

我们来到 宝塔面板 – 网站 – Node项目,安装 Node 版本管理器。

安装完毕之后,点击 添加Node项目,点击 只显示LTS版本,点击 更新版本列表

我们选择最新的 V20.18.0 稳定版安装。

创建 Node 项目

我们来到宝塔面板的文件管理器,在 wwwroot 文件夹下面创建一个文件夹 SubStore

进入 SubStore 文件夹,在里面创建 package.json 文件,并写入以下信息:

其中 v20.18.0 是刚才安装的Node的版本号,需要和刚才你安装的版本一致! 9GgGyhWFEguXZBT3oHPY ,为你的 API 密钥, 3321 为端口,可以自行更改,但是后面的反代信息需要随之变动

{
  "name": "sub-store",
  "version": "1.0.0",
  "description": "Sub-Store project",
  "main": "sub-store.bundle.js",
  "scripts": {
    "start": "SUB_STORE_FRONTEND_BACKEND_PATH=/9GgGyhWFEguXZBT3oHPY SUB_STORE_BACKEND_CRON='0 0 * * *' SUB_STORE_FRONTEND_PATH=/www/wwwroot/SubStore/dist SUB_STORE_FRONTEND_HOST=0.0.0.0 SUB_STORE_FRONTEND_PORT=3321 SUB_STORE_DATA_BASE_PATH=/www/wwwroot/SubStore SUB_STORE_BACKEND_API_HOST=127.0.0.1 SUB_STORE_BACKEND_API_PORT=3300 /www/server/nodejs/v20.18.0/bin/node /www/wwwroot/SubStore/sub-store.bundle.js"
  }
}

点击 上传/下载URL链接下载,填入下载链接

https://github.com/sub-store-org/Sub-Store/releases/latest/download/sub-store.bundle.js

如图所示:

同样的方式,下载前端文件代码

https://github.com/sub-store-org/Sub-Store-Front-End/releases/latest/download/dist.zip

VPS服务器选择:  原生IP注册  ,  高速IP购买  ,  指纹浏览器 , 中转加速降低延迟 , 泰国高速VPS , 东南亚VPS推荐