1. mkdir /xiaozhi-server
    put data models in
    mkdir codes

ronz@AISERVER:/xiaozhi-server/codes$ sudo apt install git
git clone https://github.com/xinnan-tech/xiaozhi-esp32-server.git

ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ ls
Dockerfile-server Dockerfile-web docker-setup.sh docs LICENSE main README_en.md README.md
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ mv ../../
codes/ data/ models/
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ mv ../../data ./
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ mv ../../models ./

  1. database setup
    2.1 mysql
    xiaozhi_esp32_server
    CREATE DATABASE xiaozhi_esp32_server CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    docker:docker run --name xiaozhi-esp32-server-db -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -e MYSQL_DATABASE=xiaozhi_esp32_server -e MYSQL_INITDB_ARGS="--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci" -e TZ=Asia/Shanghai -d mysql:latest

1panel - 192.168.88.88 3306 xz_user/123456

redis
docker run --name xiaozhi-esp32-server-redis -d -p 6379:6379 redis

1panel -
192.168.88.88 6379 123456

  1. runtime
    sudo apt install openjdk-21-jdk
    sudo apt install curl
    curl -sL https://deb.nodesource.com/setup_22.x | sudo -E bash -
    sudo apt install nodejs
    sudo apt install maven

curl -O https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
bash Anaconda3-2024.10-1-Linux-x86_64.sh

--run
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ cd ~/anaconda3/bin/
ronz@AISERVER:~/anaconda3/bin$ . ./activate
(base) ronz@AISERVER:~/anaconda3/bin$ cd /xiaozhi-server/codes/xiaozhi-esp32-server
(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ conda remove -n xiaozhi-esp32-server --all -y

EnvironmentLocationNotFound: Not a conda environment: /home/ronz/anaconda3/envs/xiaozhi-esp32-server

(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ conda create -n xiaozhi-esp32-server python=3.10 -y

(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server$ conda install libopus -y
conda install ffmpeg -y

--- fix ibarchive.so.20: cannot open shared object file: No such file or directory) issue

conda install -n base libarchive -c main --force-reinstall --solver classic

cd /xiaozhi-server/codes
(base) ronz@AISERVER:/xiaozhi-server/codes$ conda activate xiaozhi-esp32-server
(xiaozhi-esp32-server) ronz@AISERVER:/xiaozhi-server/codes$ cd xiaozhi-esp32-server/main/
manager-api/ manager-mobile/ manager-web/ xiaozhi-server/
(xiaozhi-esp32-server) ronz@AISERVER:/xiaozhi-server/codes$ cd xiaozhi-esp32-server/main/xiaozhi-server/
(xiaozhi-esp32-server) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/xiaozhi-server$ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
Writing to /home/ronz/.config/pip/pip.conf
(xiaozhi-esp32-server) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/xiaozhi-server$ pip install -r requirements.txt

--------WEB
ronz@AISERVER:~$ cd /xiaozhi-server/codes/xiaozhi-esp32-server/main/manager-web/
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/manager-web$ npm install
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/manager-web$ npm run serve

ronz
Password_1

-------API
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main$ ls
manager-api manager-web README.md
manager-mobile README_en.md xiaozhi-server
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main$ cd manager-api/
ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/manager-api$ ls
pom.xml README.md src

ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/manager-api$ mvn spring-boot:run

ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/xiaozhi-server$ cd ~/anaconda3/bin/
ronz@AISERVER:~/anaconda3/bin$ . ./activate
(base) ronz@AISERVER:~/anaconda3/bin$ cd /xiaozhi-server/codes/xiaozhi-esp32-server/main/
(base) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main$ conda activate xiaozhi-esp32-server
(xiaozhi-esp32-server) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main$ cd xiaozhi-server/

(xiaozhi-esp32-server) ronz@AISERVER:/xiaozhi-server/codes/xiaozhi-esp32-server/main/xiaozhi-server$ python app.py

http://192.168.88.77:8001/
ronz
Password_1
自动启动脚本

#!/bin/bash

# ==============================================================================
#                 XiaoZhi Server Auto-Start Script
# ==============================================================================
# Description: This script starts the API server, the manager web UI,
#              and the main python server in sequence. It ensures they run
#              in the background and logs their output.
#
# Author: Gemini
# Date: $(date +%Y-%m-%d)
# ==============================================================================

# --- Configuration ---
# Set the base directory for your project
PROJECT_BASE_DIR="/xiaozhi-server/codes/xiaozhi-esp32-server/main"

# Set the directory for log files. The script will create it if it doesn't exist.
LOG_DIR="/xiaozhi-server/logs"

# Path to your Anaconda installation
ANACONDA_PATH="$HOME/anaconda3"

# Name of the Conda environment to activate
CONDA_ENV_NAME="xiaozhi-esp32-server"

# --- Script Body ---

# Create log directory if it does not exist
mkdir -p "$LOG_DIR"

echo "Starting all services for XiaoZhi Server..."
echo "--------------------------------------------------"

# 1. Start the API Server (Spring Boot)
echo "[1/3] Starting API Server..."
cd "$PROJECT_BASE_DIR/manager-api" || { echo "ERROR: Directory not found: $PROJECT_BASE_DIR/manager-api"; exit 1; }
nohup mvn spring-boot:run > "$LOG_DIR/api_server.log" 2>&1 &
API_SERVER_PID=$!
echo "API Server started in the background with PID: $API_SERVER_PID. See log at $LOG_DIR/api_server.log"
echo "Waiting for 15 seconds for the API server to initialize..."
sleep 15

echo "--------------------------------------------------"

# 2. Start the Manager Web (Vue/React)
echo "[2/3] Starting Manager Web..."
cd "$PROJECT_BASE_DIR/manager-web" || { echo "ERROR: Directory not found: $PROJECT_BASE_DIR/manager-web"; exit 1; }
nohup npm run serve > "$LOG_DIR/manager_web.log" 2>&1 &
MANAGER_WEB_PID=$!
echo "Manager Web started in the background with PID: $MANAGER_WEB_PID. See log at $LOG_DIR/manager_web.log"
echo "Waiting for 10 seconds..."
sleep 10

echo "--------------------------------------------------"

# 3. Start the Main Python Server (using Conda)
echo "[3/3] Starting Main Python Server..."
# We use 'conda run' which is the recommended way to execute commands
# within a conda environment from a script. It handles the activation.
# Make sure the conda command is available in the path.
PYTHON_APP_PATH="$PROJECT_BASE_DIR/xiaozhi-server/app.py"

if [ ! -f "$PYTHON_APP_PATH" ]; then
    echo "ERROR: Python app not found: $PYTHON_APP_PATH"
    exit 1
fi

# Go to the python app's directory before running it
cd "$PROJECT_BASE_DIR/xiaozhi-server" || { echo "ERROR: Directory not found: $PROJECT_BASE_DIR/xiaozhi-server"; exit 1; }

nohup "$ANACONDA_PATH/bin/conda" run -n "$CONDA_ENV_NAME" python app.py > "$LOG_DIR/python_server.log" 2>&1 &
PYTHON_SERVER_PID=$!
echo "Main Python Server started in the background with PID: $PYTHON_SERVER_PID. See log at $LOG_DIR/python_server.log"

echo "--------------------------------------------------"
echo "All services have been launched."
echo "You can check the log files in $LOG_DIR for status."


标签: none

评论已关闭