Mac 源码部署 xiaozhi-esp32-server

brew 常用命令

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 查看通过 Homebrew 安装的软件包
brew list

# 显示已安装软件包的详细信息
brew info --installed

# 查看特定软件包信息
brew info <package>

# 更新 Homebrew 及所有已安装软件包
brew update && brew upgrade

Nginx

安装与路径说明

  • 实际安装目录
    /opt/homebrew/Cellar/nginx/1.27.5
    (包含二进制文件、配置模板等)

  • 常用操作路径(符号链接)
    /opt/homebrew/opt/nginx
    推荐使用该路径进行命令操作。

  • 核心配置文件
    /opt/homebrew/etc/nginx/nginx.conf
    修改端口、服务器块、日志等主要编辑此文件。

  • 站点配置目录
    /opt/homebrew/etc/nginx/servers/
    可在此目录下添加多个 .conf 文件(如 myapp.confapi.conf),Nginx 会自动加载。

  • 网站根目录
    /opt/homebrew/var/www
    默认网页存放路径,访问 http://localhost:8080 时显示此目录下的 index.html。如需更改,可修改 nginx.confservers/*.conf

  • 日志文件

    • 错误日志:/opt/homebrew/var/log/nginx/error.log
    • 访问日志:/opt/homebrew/var/log/nginx/access.log

常用操作命令

功能 命令
启动 Nginx(服务方式) brew services start nginx
停止 Nginx brew services stop nginx
重启 Nginx brew services restart nginx
测试配置文件语法 /opt/homebrew/opt/nginx/bin/nginx -t
重新加载配置(热重载) /opt/homebrew/opt/nginx/bin/nginx -s reload
查看 Nginx 版本 /opt/homebrew/opt/nginx/bin/nginx -v
提示
  • 默认端口为 8080,无需 sudo 即可运行。
  • 如需前台运行,可用:
    /opt/homebrew/opt/nginx/bin/nginx -g 'daemon off;'

MySQL

安装

1
2
# 使用 Homebrew 安装 MySQL
brew install mysql

常用路径

  • 实际安装目录
    /opt/homebrew/Cellar/mysql/<版本号>

  • 常用操作路径(符号链接)
    /opt/homebrew/opt/mysql

  • 配置文件
    /opt/homebrew/etc/my.cnf

  • 数据目录
    /opt/homebrew/var/mysql

  • 日志文件
    /opt/homebrew/var/mysql/*.err

常用操作命令

功能 命令
启动 MySQL(服务方式) brew services start mysql
停止 MySQL brew services stop mysql
重启 MySQL brew services restart mysql
登录 MySQL mysql -u root -p
修改 root 密码 mysqladmin -u root password '新密码'
查看版本 mysql --version

初次使用

  1. 启动服务:
    brew services start mysql

  2. 设置 root 密码(首次登录无需密码):

    1
    
    mysqladmin -u root password '你的新密码'
  3. 登录 MySQL:

    1
    
    mysql -u root -p
提示
  • 默认端口为 3306。
  • 如遇到权限或启动问题,可尝试重启服务或检查日志文件。

安装 DBeaver

地址:https://dbeaver.io/download/

遇到 Public Key Retrieval is not allowed 的错误提示

/images/posts/Mac源码部署xiaozhi-esp32-server/1.png
(图1)

安装 Redis

安装

1
2
# 使用 Homebrew 安装 Redis
brew install redis

常用路径

  • 实际安装目录
    /opt/homebrew/Cellar/redis/<版本号>

  • 常用操作路径(符号链接)
    /opt/homebrew/opt/redis

  • 配置文件
    /opt/homebrew/etc/redis.conf

  • 数据目录
    /opt/homebrew/var/db/redis

  • 日志文件
    /opt/homebrew/var/log/redis.log

常用操作命令

功能 命令
启动 Redis(服务方式) brew services start redis
停止 Redis brew services stop redis
重启 Redis brew services restart redis
启动 Redis(前台) redis-server /opt/homebrew/etc/redis.conf
连接 Redis redis-cli
查看版本 redis-server --version

初次使用

  1. 启动服务:
    brew services start redis

  2. 连接 Redis:

    1
    
    redis-cli
  3. 测试连接:
    redis-cli 中输入

    ping

    返回 PONG 表示连接成功。

提示
  • 默认端口为 6379。
  • 如遇到启动或连接问题,可检查日志文件或重启服务。

安装 Another Redis Desktop Manager

地址:https://github.com/qishibo/AnotherRedisDesktopManager?tab=readme-ov-file

Java 环境

JDK 21

地址:https://www.oracle.com/java/technologies/downloads/#jdk21-mac

/images/posts/Mac源码部署xiaozhi-esp32-server/2.png
(图2)

根目录:资源库/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home

主要通过 IDEA 使用 Java 所以就不配置环境变量了

Maven

地址:https://maven.apache.org/download.cgi

/images/posts/Mac源码部署xiaozhi-esp32-server/3.png
(图3)

配置 IDEA

/images/posts/Mac源码部署xiaozhi-esp32-server/4.png
(图4)
/images/posts/Mac源码部署xiaozhi-esp32-server/5.png
(图5)
/images/posts/Mac源码部署xiaozhi-esp32-server/6.png
(图6)

Python 环境

/images/posts/Mac源码部署xiaozhi-esp32-server/7.png
(图7)

nvm

下载安装脚本:在终端中执行以下命令来下载并运行 nvm 的安装脚本,安装脚本已经自动把环境变量写入了 ~/.zshrc,不需要我们再手动添加。

1
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.5/install.sh | bash

重新加载 .zshrc

1
source ~/.zshrc

验证 nvm 是否可用

1
nvm --version

常用命令

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 安装 Node.js 17
nvm install 17

# 使用 Node.js 17
nvm use 17

# 设置为默认版本
nvm alias default 17

# 检查当前 Node.js 和 npm 版本
node --version  # 输出:v17.x.x
npm --version # 输出:8.x.x(对应 Node 17 的 npm 版本)

xiaozhi-esp32-server

下载项目

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 查看代理
git config --global http.proxy
git config --global https.proxy

# 设置代理
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

# 清除代理
git config --global --unset http.proxy
git config --global --unset https.proxy

git clone https://github.com/xinnan-tech/xiaozhi-esp32-server.git

0%