图标
文章摘要
LIK.CC-GPT

项目地|

在 NAS 部署NeteaseCloudMusicApi 服务

  • https://github.com/Binaryify/NeteaseCloudMusicApi

  • 创建目录专门存放这些服务:
    mkdir -p /opt/repo && cd /opt/repo​

  • -克隆项目:

git clone git@github.com:Binaryify/NeteaseCloudMusicApi.git
cd NeteaseCloudMusicApi
npm install
Bash

创建 systemdctl 服务:
​vim /etc/systemd/system/NeteaseCloudMusicApi.service​
添加以下内容:

[Unit]
Description=NeteaseCloudMusicApi
[Service]
WorkingDirectory=/opt/repo/NeteaseCloudMusicApi
ExecStart=/usr/local/bin/node app.js
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Bash

服务控制相关命令:

systemctl start NeteaseCloudMusicApi.service
systemctl status NeteaseCloudMusicApi.service
systemctl stop NeteaseCloudMusicApi.service
systemctl restart NeteaseCloudMusicApi.service
systemctl enable NeteaseCloudMusicApi.service
systemctl disable NeteaseCloudMusicApi.service
Bash

部署 UNM-Server

克隆项目:

git clone git@github.com:imsyy/UNM-Server.git
cd UNM-Server
// 安装依赖
pnpm install
// 运行
pnpm start
Bash

创建 systemdctl 服务:
​vim /etc/systemd/system/UNM-Server.service​
添加以下内容:

[Unit]
Description=UNM-Server
[Service]
WorkingDirectory=/opt/repo/UNM-Server
ExecStart=/usr/local/bin/pnpm start
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Bash

服务控制相关命令:

systemctl start UNM-Server.service
systemctl status UNM-Server.service
systemctl stop UNM-Server.service
systemctl restart UNM-Server.service
systemctl enable UNM-Server.service
systemctl disable UNM-Server.service
Bash

部署 SPlayer 服务

同样在/opt/repo 文件目录克隆项目

git clone git@github.com:imsyy/SPlayer.git
Bash

修改环境变量:

vim .env
# 修改里面的API地址,修改为:http://localhost:3000/
Bash

安装依赖

pnpm install
# 或者
yarn install
# 或者
npm install
Bash

开发

pnpm dev
# 或者
yarn dev
# 或者
npm dev
Bash

构建

pnpm build
# 或者
yarn build
# 或者
npm build
Bash

如果遇到打包不了的情况可以安装:npm install -g pnpm​
使用Nginx 部署 dist 页面:
在这个路径下:/etc/nginx/sites-enabled​创建一个配置文件:splayer​

server {
    listen 1163;
    server_name _;
    root /opt/repo/SPlayer/dist;
    index index.html;
    gzip  on;
    gzip_min_length  1k;
    gzip_comp_level 3;
    gzip_types  text/xml text/plain text/css application/javascript application/x-javascript application/rss+xml text/javascript image/tiff image/svg+xml application/json application/xml;
    gzip_vary on;
    location  ~assets/ {
        expires max;
    }
    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
}
nginx

使用 nginx -t​ 查看配置文件是否有误
使用 nginx -s reload​来更新服务