第一步:安装所需组件
apt update -y && apt install unzip curl wget git sudo -y
第二步:安装 FNM 版本管理器
curl -fsSL https://fnm.vercel.app/install | bash
source /root/.bashrc #安装完成执行
第三步:FNM 安装 Node
fnm install v20.18.0
node -v # 回显返回版本号即为安装成功
第四步:安装 PNPM 软件包管理器
curl -fsSL https://get.pnpm.io/install.sh | sh -
source /root/.bashrc #安装完成按照提示执行
第五步:安装 Sub-Store
5-1.创建文件夹
mkdir -p /root/sub-store && cd sub-store
5-2.拉取项目并解压
#拉取后端项目
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
第六步:创建系统服务
6-1.在/etc/systemd/system/文件下下面创建一个sub-store.service文件
vim /etc/systemd/system/sub-store.service
6-2.写入以下信息,Api请求密钥:9vUgbmi2oP5v0FevHvuW 端口自己设置:3000,3001
[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=/9vUgbmi2oP5v0FevHvuW"
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=3000"
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=3001"
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
上面服务代码中的 9vUgbmi2oP5v0FevHvuW
为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 #重启服务
systemctl daemon-reload #重载系统服务
正常情况下,运行服务状态,应该类似下图:( active:running
)
到这里已经可以通过IP+端口进行访问了:
# 9vUgbmi2oP5v0FevHvuW 为你的 API 请求密钥
http://IP:3000/?api=http://IP:3000/9vUgbmi2oP5v0FevHvuW
发表回复