Sub-Store 搭建教程(支持无面板与宝塔面板)
标签搜索
侧边栏壁纸
博主昵称
BG

  • 累计撰写 29 篇文章
  • 累计收到 23 条评论

Sub-Store 搭建教程(支持无面板与宝塔面板)

BG
BG
2025-04-19 / 0 评论 / 2 阅读 / 正在检测是否收录...

Sub-Store 搭建教程(支持无面板与宝塔面板)

【准备工作】

  1. VPS 一台,重置 Debian 12 操作系统(本文以这个为例)
  2. 域名 一个,托管到 Cloudflare,并转向 VPS IP

一、无宝塔面板部署

1. 更新系统 && 安装必要组件

apt update -y
apt install unzip curl wget git sudo -y

2. 安装 Node.js

curl -fsSL https://fnm.vercel.app/install | bash
source /root/.bashrc
fnm install v20.18.0
node -v  # 看到版本即为成功

3. 安装 PNPM

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

4. 安装 Sub-Store

mkdir -p /root/sub-store && cd /root/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
unzip dist.zip && mv dist frontend && rm dist.zip

5. 创建系统服务 sub-store.service

cat > /etc/systemd/system/sub-store.service <<EOF
[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
EOF

6. 启动服务 && 设置自启

systemctl daemon-reload
systemctl enable sub-store.service
systemctl start sub-store.service
systemctl status sub-store.service

7. 安装 Nginx 并配置反向代理 + SSL

apt install nginx -y

域名设置 & SSL

将域名 A 记录指向 VPS IP,开启 CF 代理;证书保存路径:

/root/cert/ssl.pem
/root/cert/ssl.key

Nginx 配置

cat > /etc/nginx/sites-enabled/sub-store.conf <<EOF
server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name sub.yourdomain.com;

  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;
  }
}
EOF

重载 Nginx

nginx -t && nginx -s reload

访问地址:https://sub.yourdomain.com/?api=https://sub.yourdomain.com/9GgGyhWFEguXZBT3oHPY


二、宝塔面板部署方式

1. 安装 Node.js 管理器

宝塔面板 > 软件商店 > Node项目管理器 > 安装,安装完后点击添加项目并选择 LTS 版本:v20.18.0。

2. 准备项目文件夹

宝塔文件管理 > wwwroot 目录下新建文件夹 SubStore

3. 创建 package.json

进入 SubStore 文件夹,创建 package.json 文件:

{
  "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"
  }
}

4. 下载前后端代码

在当前目录使用 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

解压 dist.zip 并重命名为 dist

5. 添加 Node 项目

宝塔 > Node项目 > 添加项目:

  • 项目路径:/www/wwwroot/SubStore
  • 启动端口:3321
  • Node版本:选择 v20.18.0
  • 启用随系统启动 ✅

6. 配置反向代理 & SSL

宝塔 > 网站 > 添加站点(填入域名)> SSL:粘贴证书 & 密钥 > 开启强制 HTTPS

反代设置:目标 URL 填写:http://127.0.0.1:3321

访问地址:https://sub.yourdomain.com/?api=https://sub.yourdomain.com/9GgGyhWFEguXZBT3oHPY


三、更新 Sub-Store

无面板方式:

systemctl stop sub-store.service
cd /root/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

宝塔方式:

停止 Node 项目服务,删除旧的 sub-store.bundle.js,重新上传新版本即可。


四、值得推荐的 rename.js 节点编排脚本

https://raw.githubusercontent.com/Keywos/rule/main/rename.js

配合 Sub-Store 用于自动编排节点,可配合 Sub-Store 后台设置 JS 链接自动进行节点重命名。


五、结言

Sub-Store 是一个很实用的节点管理工具,支持多机场合并订阅,自带节点配合,配合自定义规则和 emoji 等,有效改善合同节点最终显示效果,非常值得学习和使用。

0

评论

博主关闭了当前页面的评论