yiye

一叶轻舟

记录人生旅途的轻声细语

Mix Space 博客搭建指南

入门篇:Docker 部署#

推荐指数:★★★★★

难度指数:★

使用 Docker 部署,前后端不做分离,部署要求如下:

  • 1 台服务器,要求内存 >1G
  • 1 个域名(国内服务器需备案)

注意:后端默认不带主题,运行服务后还需登入后台管理界面 https://www.blog.com/proxy/qaqdmin 参照 云函数 配置主题

配置文件#

文件目录结构如下,.envdocker-compose.yml需要用户创建,data 目录在容器运行后自动生成

📂 ~/mix-space

├── 📜 .env
├── 📜 docker-compose.yml
└── 📂 data
    ├── 📂 mongo
    ├── 📂 redis
    └── 📂 core

.env#

注意:API 相关配置 一般不需修改

# 💻 前端配置
# 🌐 API 相关配置
NEXT_PUBLIC_API_URL=http://core:2333/api/v2
NEXT_PUBLIC_GATEWAY_URL=http://core:2333/

# 🔑 认证 & API 密钥
TMDB_API_KEY=
GH_TOKEN=

# 🖥️ 后端配置
# 🔐 安全性配置
JWT_SECRET=G7xJpQzW8mV4L2YfK9N6T1RbX3dMC0H(32位)
ALLOWED_ORIGINS=
ENCRYPT_KEY=593f62860255feb0a914534a43814b9809cc7534da7f5485cd2e3d3c8609acab(64位)
ENCRYPT_ENABLE=false

# 🚀 缓存相关配置
CDN_CACHE_HEADER=true
FORCE_CACHE_HEADER=false

# 🛢 数据库配置
MONGO_CONNECTION=

# ⚡ 请求限流(Throttle)
THROTTLE_TTL=10
THROTTLE_LIMIT=20

dockers-compose.yml#

services:
  shiro:
    container_name: shiro
    image: innei/shiro:latest
    volumes:
      - ./.env:/app/.env
    restart: always
    environment:
      - NEXT_SHARP_PATH=/usr/local/lib/node_modules/sharp
    ports:
      - "127.0.0.1:2323:2323"
    depends_on:
      - core
    networks:
      - mix-space

  core:
    container_name: core
    image: innei/mx-server:latest
    environment:
      - TZ=Asia/Shanghai
      - NODE_ENV=production
      - DB_HOST=mongo
      - REDIS_HOST=redis
    volumes:
      - ./data/core:/root/.mx-space
    ports:
      - "127.0.0.1:2333:2333"
    depends_on:
      - mongo
      - redis
    networks:
      - mix-space
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://127.0.0.1:2333/api/v2/ping"]
      interval: 1m30s
      timeout: 30s
      retries: 5
      start_period: 30s

  mongo:
    container_name: mongo
    image: mongo
    volumes:
      - ./data/mongo:/data/db
    networks:
      - mix-space
    restart: unless-stopped

  redis:
    image: redis:alpine
    container_name: redis
    volumes:
      - ./data/redis:/data
    healthcheck:
      test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
      start_period: 20s
      interval: 30s
      retries: 5
      timeout: 3s
    networks:
      - mix-space
    restart: unless-stopped

networks:
  mix-space:
    driver: bridge

nginx 反代#

请在域名(以www.blog.com为例)添加一条 A 记录指向服务器 IP,然后添加以下 server 块

server {
    listen 80;
    listen 443 ssl http2 ; 
   
    server_name www.blog.com; 
    index index.html; 
    proxy_set_header Host $host; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Host $server_name; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    error_log /www/sites/www.example.com/log/error.log;
    access_log /www/sites/www.example.com/log/access.log; 
    location /socket.io {
        proxy_set_header Upgrade $http_upgrade; 
        proxy_set_header Connection "Upgrade"; 
        proxy_set_header Host $host; 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        proxy_set_header X-Forwarded-Proto $scheme; 
        proxy_pass http://127.0.0.1:2333/socket.io; 
    }
    location /api/v2 {
        proxy_pass http://127.0.0.1:2333/api/v2; 
    }
    location /render {
        proxy_pass http://127.0.0.1:2333/render; 
    }
    location / {
        proxy_pass http://127.0.0.1:2323; 
    }
    location /qaqdmin {
        proxy_pass http://127.0.0.1:2333/proxy/qaqdmin;
    }
    location /proxy {
        proxy_pass http://127.0.0.1:2333/proxy;
    }
 
    location ~* \/(feed|sitemap|atom.xml) {
        proxy_pass http://127.0.0.1:2333/$1; 
    }
    ssl_certificate /www/sites/www.example.com/ssl/fullchain.pem; 
    ssl_certificate_key /www/sites/www.example.com/ssl/privkey.pem; 
    ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1; 
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK'; 
    ssl_prefer_server_ciphers on; 
    ssl_session_cache shared:SSL:10m; 
    ssl_session_timeout 10m; 
    error_page 497 https://$host$request_uri; 
    limit_conn perserver 300; 
    limit_conn perip 25; 
    limit_rate 512k; 
}

进阶篇:传统方法部署#

推荐指数:★★★

难度指数:★★★

构建部署,前后端分离,部署要求如下:

  • 简单部署 / 自动部署

    • 1 台服务器,要求内存 >1G

    • 2 个域名,可以是子域名

  • 手动部署

    • 1 台服务器,要求内存 >2G
    • 2 个域名,可以是子域名

注意:后端默认不带主题,运行服务后还需登入后台管理界面 https://backend.blog.com/proxy/qaqdmin 参照 云函数 配置主题

构建后端#

准备环境#

  • 安装 nodejs,建议安装 20.12.2 版本

    sudo apt-get install curl
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
    nvm install 20.12.2
    
  • 安装 redis

    sudo apt-get install redis-server
    
  • 安装 mongodb,这里以 Ubuntu 24.04 为例

    sudo apt-get install gnupg
    
    curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
       sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
       --dearmor
    echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
    
    sudo apt-get update
    sudo apt-get install -y mongodb-org
    sudo systemctl start mongod
    sudo systemctl enable mongod
    sudo systemctl status mongod
    

    其余系统安装可参考:MongoDB 官方文档

简单部署#

后端仓库:Mix Space/core

  • 直接下载构建好的 linux 版

    mkdir ~/mix-space/core && cd $_
    curl -L -O https://github.com/mx-space/core/releases/latest/download/release-linux.zip
    unzip release-linux.zip
    rm release-linux.zip
    
  • 生成 32 位和 64 位字符

    openssl rand -base64 24 | cut -c1-32 # 用于jwt_secret
    openssl rand -base64 48 | cut -c1-64 # 用于encrypt key
    
  • 编辑ecosystem.config.js

    const { cpus } = require('os');
    const { execSync } = require('child_process');
    const nodePath = execSync(`npm root --quiet -g`, { encoding: 'utf-8' }).trim();
    const cpuLen = cpus().length;
    
    module.exports = {
      apps: [
        {
          name: 'mix-space',
          script: 'index.js',
          autorestart: true,
          exec_mode: 'cluster',
          watch: false,
          instances: cpuLen,
          max_memory_restart: '500M',
          args: [
            '--color',
            '--encrypt_enable',
            '--encrypt_key ********************************(64位)',
            '--port 2333',
            '--allowed_origins example1.com,example2.com,localhost',
            '--jwt_secret ********************(16~32位)',
          ].join(' '),
          env: {
            NODE_ENV: 'production',
            NODE_PATH: nodePath,
          },
        },
      ],
    };
    
  • 启动后端服务

    npm install -g pm2
    pm2 start ecosystem.config.js
    

手动部署#

  • 安装后端服务

    mkdir ~/mix-space && cd $_
    git clone https://github.com/mx-space/core.git --depth=1
    cd core
    npm install -g pnpm
    pnpm i
    
  • 构建后端服务

    pnpm build
    pnpm bundle
    
  • 创建符号链接,并参照 简单部署 修改 ecosystem.config.js

    ln -s ./app/core/ecosystem.config.js ecosystem.config.js
    
  • 启动后端服务

    npm install -g pm2
    pm2 start ecosystem.config.js
    

构建前端#

准备环境#

  • 安装依赖

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
    nvm install 20.12.2
    npm install -g pnpm pm2 
    npm i -g sharp
    

简单部署#

  • 前端仓库:Innie/Shiro

  • 直接下载构建好的 linux 版

    mkdir ~/mix-space/shiro && cd $_
    curl -L -O https://github.com/Innei/Shiro/releases/latest/download/release.zip
    unzip release.zip
    rm release.zip
    
  • 编辑ecosystem.config.js

    module.exports = {
      apps: [
        {
          name: 'shiro',
          script: 'server.js',
          autorestart: true,
          watch: false,
          max_memory_restart: '500M',
          env: {
            PORT: 2323,
            NODE_ENV: 'production',
            NEXT_SHARP_PATH: process.env.NEXT_SHARP_PATH,
    	    NEXT_PUBLIC_API_URL: 'http://127.0.0.1:2323/api/v2',
    	    NEXT_PUBLIC_GATEWAY_URL: 'http://127.0.0.1:2323'
          },
          log_date_format: 'YYYY-MM-DD HH:mm:ss',
        },
      ],
    }
    
  • 启动前端服务

    pm2 start ecosystem.config.js
    

自动部署#

  • 创建前端目录

    mkdir -p ~/mix-space/shiro && cd $_
    

    编辑环境变量.env

    NEXT_PUBLIC_API_URL=https://example.net/api/v2
    NEXT_PUBLIC_GATEWAY_URL=https://example.net
    TMDB_API_KEY=
    GH_TOKEN=
    
  • Fork 前端仓库,等待完成后进入 Actions 标签启用 Workflow,接着进入 Settings 标签,左侧点击 [Secrets and variables] - [Actions] - [New repository secret] 添加以下变量

NameSecretDescription
HOSTexample.comSSH 登录地址
PORT22SSH 登录端口
USERadminSSH 登录用户名
PASSWORDP@ssw0rdSSH 登录密码,与 KEY 二选一
KEYssh-rsa*****SSH 私钥,与 PASSWORD 二选一
  • 切换到 Code 标签,新建.github/workflows/deploy.yml

    name: Deploy
    
    on:
      push:
        branches: [main]
    
    permissions:
      contents: write
    
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: true
    
    jobs:
      build:
        name: Build artifact
        runs-on: ubuntu-latest
        strategy:
          matrix:
            node-version: [20.x]
        steps:
          - uses: actions/checkout@v4
            with:
              fetch-depth: 0
              lfs: true
    
          - name: Checkout LFS
            run: git lfs checkout
    
          - uses: pnpm/action-setup@v2
            with:
              version: 9.x.x
    
          - name: Setup Node.js
            uses: actions/setup-node@v4
            with:
              node-version: ${{ matrix.node-version }}
              cache: 'pnpm'
    
          - uses: jongwooo/next-cache@v1
    
          - name: Install & Build
            run: |
              pnpm install
              sh ./ci-release-build.sh
    
          - uses: actions/upload-artifact@v4
            with:
              name: release.zip
              path: assets/release.zip
    
      deploy:
        name: Deploy artifact
        runs-on: ubuntu-latest
        needs: build
        steps:
          - uses: actions/download-artifact@v4
            with:
              name: release.zip
    
          - name: SCP Transfer
            uses: appleboy/[email protected]
            with:
              host: ${{ secrets.HOST }}
              username: ${{ secrets.USER }}
              key: ${{ secrets.KEY }}
              password: ${{ secrets.PASSWORD }}
              port: ${{ secrets.PORT }}
              source: release.zip
              target: /tmp/shiro
    
          - name: Remote Deployment
            uses: appleboy/[email protected]
            with:
              host: ${{ secrets.HOST }}
              username: ${{ secrets.USER }}
              key: ${{ secrets.KEY }}
              password: ${{ secrets.PASSWORD }}
              port: ${{ secrets.PORT }}
              script: |
                set -ex
                source $HOME/.bashrc
                basedir=$HOME/mix-space/shiro
                workdir=$basedir/${{ github.sha }}
                mkdir -p $workdir
                mkdir -p $basedir/.cache
                mv /tmp/shiro/release.zip $workdir/release.zip
                rm -r /tmp/shiro
                cd $workdir
                unzip -qq -o $workdir/release.zip
                rm -rf $workdir/standalone/.env
                ln -s $HOME/shiro/.env $workdir/standalone/.env
                export NEXT_SHARP_PATH=$(npm root -g)/sharp
                # copy workdir ecosystem.config.js to basedir if not exists
                if [ ! -f $basedir/ecosystem.config.js ]; then
                  cp $workdir/standalone/ecosystem.config.js $basedir/ecosystem.config.js
                fi
                # https://github.com/Unitech/pm2/issues/3054
                # symlink workdir node entry file to basedir
                ln -sf $workdir/standalone/server.js $basedir/server.js
                mkdir -p $workdir/standalone/.next
                rm -rf $workdir/standalone/.next/cache
                ln -sf $basedir/.cache $workdir/standalone/.next/cache
                cd $basedir
                pm2 reload ecosystem.config.js --update-env
                rm $workdir/release.zip
                pm2 save
                echo "Deployed successfully"
    
  • 点击 Sync fork 可以同步官方仓库的更新,同步后会触发自动部署

  • 另外,也可 点击创建 一键部署到 vercel,注意添加环境变量,同步仓库也会自动更新

配置 nginx#

  • 前端配置

    location ~* \.(gif|png|jpg|css|js|woff|woff2|svg|webp)$ {
      proxy_pass http://127.0.0.1:2323;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header REMOTE-HOST $remote_addr;
      expires 30d;
    }
    location ~* \/(feed|sitemap|atom.xml) {
      proxy_pass http://127.0.0.1:2333/$1;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header REMOTE-HOST $remote_addr;
      add_header X-Cache $upstream_cache_status;
      add_header Cache-Control max-age=60;
    }
    location / {
      proxy_pass http://127.0.0.1:2323;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header REMOTE-HOST $remote_addr;
      add_header X-Cache $upstream_cache_status;
      add_header Cache-Control no-cache;
      proxy_intercept_errors on;
    }
    
  • 后端配置

    location /socket.io {
      proxy_pass http://127.0.0.1:2333/socket.io; 
      proxy_set_header Host $host; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_set_header REMOTE-HOST $remote_addr; 
      proxy_set_header Upgrade $http_upgrade; 
      proxy_set_header Connection "upgrade"; 
      proxy_buffering off;
      proxy_http_version 1.1; 
      add_header Cache-Control no-cache; 
    }
    
    location / {
      proxy_pass http://127.0.0.1:2333; 
      proxy_set_header Host $host; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_set_header REMOTE-HOST $remote_addr; 
      add_header X-Cache $upstream_cache_status; 
    }    
    

特别篇一:render 部署#

推荐指数:★★★★

难度指数:★★★★

准备工作#

  1. 注册 mongoDB
  2. 注册 github
  3. 注册 render
  4. 注册 vercel

搭建框架#

  • MongoDB 数据库
  • Render 部署 Redis 缓存
  • Vercel 托管的前端主题 Shiro
  • Render 部署后端 Mix Space
📦 项目结构
├── 🗄️ 数据库 (MongoDB)
│   ├── 📂 用户数据
│   ├── 📂 文章数据
│   ├── 📂 其他业务数据

├── 🔥 缓存层 (Redis - Render 部署)
│   ├── ⚡ 存储会话信息
│   ├── ⚡ 存储热点数据
│   ├── ⚡ 降低数据库查询压力

├── 🎨 前端 (Shiro 主题 - Vercel 托管)
│   ├── 📦 依赖: Next.js / React
│   ├── 🎨 UI 组件
│   ├── 🔗 调用后端 API
│   ├── ⚙️ 状态管理

├── 🚀 后端 (Mix Space - Render 部署)
│   ├── 📦 依赖: Nest.js
│   ├── 🔗 连接 MongoDB
│   ├── 🔗 连接 Redis 缓存
│   ├── 🔒 认证 & 授权
│   ├── 📡 API 处理

└── 🌐 部署
    ├── 📤 前端部署到 Vercel
    ├── 📤 后端 & Redis 部署到 Render
    ├── 🛠️ CI/CD 自动化

注意:后端默认不带主题,运行服务后还需登入后台管理界面 https://www.blog.com/proxy/qaqdmin 参照教程最后 云函数 配置主题

开始搭建#

  1. 数据库:MongoDB

    创建步骤参考 抱脸部署 LibreChat 教程 , 这里不再赘述

  2. 缓存:Redis

    • 登陆 render,依次点击右上角 +Key Value
    • Name 填写 redis
    • Project 选择 Production
    • Region 选择 Singapore
    • Instance Type 选择 Free
    • 点击 Create Key Value Instance 创建
    • 下拉在 Connections 下复制 Internal Key Value URL,形如 redis://red-cvdd4eofnakc738i3f00:6379,粘贴到剪贴板后只保留中间部分red-cvdd4eofnakc738i3f00 作为 REDIS_HOST
  3. 前端:Shiro

    • 点击创建,名称填写 shiro,修改环境变量后点击 Deploy 部署

      NameValueDescription
      NEXT_PUBLIC_API_URLhttps://backend.blog.com/api/v2后端 API 接口地址
      NEXT_PUBLIC_GATEWAY_URLhttps://backend.blog.com/后端域名
    • 修改区域,在 Settings - Functions - Function Region 选择 Asia - Hong Kong,注意先取消勾选再选择

    • 自定义域,注意 vercel 分配的域名国内无法直连需要添加自定义域:

      1. 在 cloudflare 需要绑定的域名添加一条 A 记录指向 76.223.126.88
      2. 进入 vercel 的 shiro 项目依次点击 Settings - Domains - Add
      3. 输入绑定的域名,然后点击 Add Domain,注意勾选第三项后点击 Add 完成域名自定义

      这里假定添加的自定义域为 frontend.blog.com

  4. 后端:Mix Space

    • 登录 render,依次点击右上角 +Web Service

    • 选择 Existing imageImage URL 输入 innei/mx-server:latest

    • 稍等几秒,点击 Connect

    • Name 修改为 core

    • Project 选择 Production

    • Region 选择 Singapore

    • Instance Type 选择 Free

    • Environment Variables 下方点击 Add from .env,修改以下环境变量后粘贴到输入框

      ALLOWED_ORIGINS=frontend.blog.com
      REDIS_HOST=red-cvdd4eofnakc738i3f00
      DB_CONNECTION_STRING=mongodb+srv://<DB_USER>:<DB_PASSWORD>@<DB_USER>
      JWT_SECRET=************************
      

      其中JWT_SECRET可通过以下命令快速生成

      openssl rand -base64 24 | cut -c1-32
      
    • 点击 Deploy Web Service 部署

    • 下滑在 Custom Domains 下方点击 + Add Custom Domain,输入自定义域,格式如 backend.blog.com

    • 按提示前往域名托管处,如 cloudflare,添加一条 CNAME 记录后返回点击 verify 验证

特别篇二:serv00 部署#

推荐指数:★★★

难度指数:★★★★★

准备环境#

mkdir -p ~/.npm-global && npm config set prefix "$HOME/.npm-global" && echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.profile && source ~/.profile && npm install -g pm2 && pm2

mkdir ~/.mx-space
npm install [email protected] --prefix ~/.mx-space

准备存储#

devil mongo db add core

devil port add tcp 5555
cd ~/domains/***.serv00.net

fetch https://raw.githubusercontent.com/redis/redis/7.4/redis.conf

sed -i '' "s/^port .*/port 5555/" redis.conf
sed -i '' -E "s/^# requirepass .*/requirepass secure_pass/" redis.conf
sed -i '' 's/^appendonly no$/appendonly yes/' redis.conf

screen redis-server redis.conf

同时按住 CTRL+A+D 退出 screen 后,测试 redis

redis-cli -h 127.0.0.1 -p 5555 -a secure_pass ping

运行成功会返回PONG

安装后端#

注意:后端默认不带主题,运行服务后还需登入后台管理界面 https://www.blog.com/proxy/qaqdmin 参照教程最后 云函数 配置主题

mkdir -p ~/domains/***.serv00.net/mix-space/core && cd $_
wget https://github.com/mx-space/core/releases/latest/download/release-linux.zip
unzip release-linux.zip
rm release-linux.zip

cat > ecosystem.config.js <<EOF
const { execSync } = require('node:child_process');
const nodePath = execSync(`npm root --quiet -g`, { encoding: 'utf-8' }).trim();
module.exports = {
  apps: [
    {
      name: 'core',
      script: 'index.js',
      autorestart: true,
      watch: false,
      max_memory_restart: '500M',
      args: [
        '--color',
        '--encrypt_enable',
        '--encrypt_key ********************(64位)',
        '--redis_host 127.0.0.1',
        '--redis_port 5555',
        '--redis_password ********',
        '--db_host mongo15.serv00.com',
        '--collection_name mix-space',
        '--db_user mix-space',
        '--db_password ********',
        '--port 2333',
        '--allowed_origins example1.com,example2.com,localhost',
        '--jwt_secret *************(32位)',
      ].join(' '),
      env: {
        NODE_ENV: 'production',
        NODE_PATH: nodePath,
      },
    },
  ],
};
EOF

pm2 start ecosystem.config.js

安装前端#

mkdir -p ~/domains/***.serv00.net/mix-space/shiro && cd $_
curl -L -O https://github.com/Innei/Shiro/releases/latest/download/release.zip
unzip release.zip
rm release.zip

cat > ecosystem.config.js <<EOF 
module.exports = {
  apps: [
    {
      name: 'shiro',
      script: 'server.js',
      autorestart: true,
      watch: false,
      max_memory_restart: '500M',
      env: {
        PORT: 2323,
        NODE_ENV: 'production',
        NEXT_SHARP_PATH: process.env.NEXT_SHARP_PATH,
	    NEXT_PUBLIC_API_URL: 'http://127.0.0.1:2323/api/v2',
	    NEXT_PUBLIC_GATEWAY_URL: 'http://127.0.0.1:2323'
      },
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
    },
  ],
}
EOF

pm2 start ecosystem.config.js

云函数#

Shiro 主题#

  • 登入后台点击左侧底部 附加功能 - 配置与云函数,点击 + 新建

  • 名称 填写 shiro引用 填写 theme ,并在右侧代码区粘贴以下代码,请自行酌情修改

    {
      "footer": {
        "otherInfo": {
          "date": "2020-{{now}}",
          "icp": {
            "text": "萌 ICP 备 20236136 号",
            "link": "https://icp.gov.moe/?keyword=20236136"
          }
        },
        "linkSections": [
          {
            "name": "关于",
            "links": [
              {
                "name": "关于本站",
                "href": "/about-site"
              },
              {
                "name": "关于我",
                "href": "/about"
              },
              {
                "name": "关于此项目",
                "href": "https://github.com/innei/Shiro",
                "external": true
              }
            ]
          },
          {
            "name": "更多",
            "links": [
              {
                "name": "时间线",
                "href": "/timeline"
              },
              {
                "name": "友链",
                "href": "/friends"
              },
              {
                "name": "监控",
                "href": "https://status.innei.in/status/main",
                "external": true
              }
            ]
          },
          {
            "name": "联系",
            "links": [
              {
                "name": "写留言",
                "href": "/message"
              },
              {
                "name": "发邮件",
                "href": "mailto:[email protected]",
                "external": true
              },
              {
                "name": "GitHub",
                "href": "https://github.com/innei",
                "external": true
              }
            ]
          }
        ]
      },
      "config": {
        "color": {
          "light": [
            "#33A6B8",
            "#FF6666",
            "#26A69A",
            "#fb7287",
            "#69a6cc",
            "#F11A7B",
            "#78C1F3",
            "#FF6666",
            "#7ACDF6"
          ],
          "dark": [
            "#F596AA",
            "#A0A7D4",
            "#ff7b7b",
            "#99D8CF",
            "#838BC6",
            "#FFE5AD",
            "#9BE8D8",
            "#A1CCD1",
            "#EAAEBA"
          ]
        },
     
        "bg": [
          "https://github.com/Innei/static/blob/master/images/F0q8mwwaIAEtird.jpeg?raw=true",
          "https://github.com/Innei/static/blob/master/images/IMG_2111.jpeg.webp.jpg?raw=true"
        ],
        "custom": {
          "css": [],
          "styles": [],
          "js": [],
          "scripts": []
        },
        "site": {
          "favicon": "/innei.svg",
          "faviconDark": "/innei-dark.svg"
        },
        "hero": {
          "title": {
            "template": [
              {
                "type": "h1",
                "text": "Hi, I'm ",
                "class": "font-light text-4xl"
              },
              {
                "type": "h1",
                "text": "Innei",
                "class": "font-medium mx-2 text-4xl"
              },
              {
                "type": "h1",
                "text": "👋。",
                "class": "font-light text-4xl"
              },
              {
                "type": "br"
              },
              {
                "type": "h1",
                "text": "A NodeJS Full Stack ",
                "class": "font-light text-4xl"
              },
              {
                "type": "code",
                "text": "<Developer />",
                "class": "font-medium mx-2 text-3xl rounded p-1 bg-gray-200 dark:bg-gray-800/0 hover:dark:bg-gray-800/100 bg-opacity-0 hover:bg-opacity-100 transition-background duration-200"
              },
              {
                "type": "span",
                "class": "inline-block w-[1px] h-8 -bottom-2 relative bg-gray-800/80 dark:bg-gray-200/80 opacity-0 group-hover:opacity-100 transition-opacity duration-200 group-hover:animation-blink"
              }
            ]
          },
          "description": "An independent developer coding with love."
        },
        "module": {
          "activity": {
            "enable": true,
            "endpoint": "/fn/ps/update"
          },
          "donate": {
            "enable": true,
            "link": "https://afdian.net/@Innei",
            "qrcode": [
              "https://cdn.jsdelivr.net/gh/Innei/img-bed@master/20191211132347.png",
              "https://cdn.innei.ren/bed/2023/0424213144.png"
            ]
          },
          "bilibili": {
            "liveId": 1434499
          }
        }
      }
    }
    

PS 状态插件#

  • 登入后台点击左侧底部 附加功能 - 配置与云函数,点击 + 新建
  • 名称 填写 update引用 填写 ps数据类型 选择 Function请求方式 选择 POSTSecret 左侧输入框填入 key,右侧填入 key 的值,然后 点击前往 全选复制所有内容粘贴到右侧代码区,最后点击绿色按钮保存
  • 下载安装 Kizuna,Windows 系统快捷键 WIN + R 输入 notepad %USERPROFILE%\AppData\Local\kizuna\config.yml 编辑
server_config:
  endpoint: "https://backend.example.com/api/v2/fn/ps/update" # https://api.example.com/api/v2/fn/ps/update
  token: "YOUR-KEY-HERE" # 设置的key
  report_time: 5 # 上报时间间隔,单位秒
rules: # 软件名的替换规则
  - match_application: WeChat
    replace:
      application: 微信
      description: 一个小而美的办公软件
  - match_application: QQ
    replace:
      application: QQ
      description: 一个多功能的通讯软件
  - match_application: Netease Cloud Music
    replace:
      application: 网易云音乐
      description: 一个音乐播放和分享的平台          

编辑好后 CTRL + S 保存并关闭,然后再运行 Kizuna,就会定时往定义的端点上传你的活动数据

参考链接#

Mix Space 官方文档

Mix-Space 部署最新前端 Shiro

Mix-Space 搭建从入门到入土

此文由 Mix Space 同步更新至 xLog
原始链接为 https://reno.zone.id/posts/default/mix-space-blog-guide


加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。