安装指南
大约 4 分钟
安装指南
本节将帮助你完成运行祺洛所需的环境准备与基础配置,不使用 Docker。
环境要求
- 操作系统:macOS / Linux / Windows(推荐 WSL2)
- Rust:stable(通过 rustup 安装)
- Node.js:≥ 18(建议使用 pnpm)
- 数据库:PostgreSQL 或 MySQL(示例以 PostgreSQL)
- Redis(可选):缓存 / 分布式锁 / 队列
- 构建依赖:pkg-config、OpenSSL(Linux 常见为 libssl-dev)
安装工具
安装 Rust(https://www.rust-lang.org/zh-CN/tools/install) 安装MySql (https://www.mysql.com/) 安装Redis (https://redis.io/download/)
获取源码
后端地址
克隆后端项目
GitHub https://github.com/chelunfu/qiluo_admin.git
git clone https://github.com/chelunfu/qiluo_admin.git
cd qiluo_admin
GitCode https://gitcode.com/will_csdn_go/qiluo_admin.git
git clone https://gitcode.com/will_csdn_go/qiluo_admin.git
cd qiluo_admin
Gitee https://gitee.com/chenlunfu/qiluo_admin.git
git clone https://gitee.com/chenlunfu/qiluo_admin.git
cd qiluo_admin
前端地址
克隆前端项目
GitHub https://github.com/chelunfu/qiluo_vue.git
git clone https://github.com/chelunfu/qiluo_vue.git
cd qiluo_vue
GitCode https://gitcode.com/will_csdn_go/qiluo_vue.git
git clone https://gitcode.com/will_csdn_go/qiluo_vue.git
cd qiluo_vue
Gitee https://gitee.com/chenlunfu/qiluo_vue.git
git clone https://gitee.com/chenlunfu/qiluo_vue.git
cd qiluo_vue
后端配置
创建 config/default.toml,并填写必要参数:
# Web server configuration
server:
# The server domain name.
domainname: http://localhost:5001
# Port on which the server will listen. the server binding is 0.0.0.0:{PORT}
port: 5001
# The UI hostname or IP address that mailers will point to.
host: 0.0.0.0
# The directory where the static files will be served from.
static_dir: data/static
# The directory where the web files will be served from.
web_dir: data/web
# The directory where the upload files will be served from.
upload_dir: data/upload
# SSl configuration
ssl:
enable: false
key: data/ssl/key.pem
cert: data/ssl/cert.pem
# Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block
middlewares:
# Enable Etag cache header middleware
etag:
enable: true
# Allows to limit the payload size request. payload that bigger than this file will blocked the request.
limit_payload:
# Enable/Disable the middleware.
enable: true
# the limit size. can be b,kb,kib,mb,mib,gb,gib
body_limit: 5mb
# Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details.
logger:
# Enable/Disable the middleware.
enable: true
# when your code is panicked, the request still returns 500 status code.
catch_panic:
# Enable/Disable the middleware.
enable: true
# Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned.
timeout_request:
# Enable/Disable the middleware.
enable: false
# Duration time in milliseconds.
timeout: 5000
cors:
enable: true
# Set the value of the [`Access-Control-Allow-Origin`][mdn] header
allow_origins:
- http://localhost:4000
# Set the value of the [`Access-Control-Allow-Headers`][mdn] header
# allow_headers:
# - Content-Type
# Set the value of the [`Access-Control-Allow-Methods`][mdn] header
# allow_methods:
# - POST
# Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds
max_age: 3600
# Worker Configuration
workers:
qeueu:
- default
num_workers: 1
# Database Configuration
database:
# Database connection URI
uri: {{get_env(name="DATABASE_URL",default="mysql://qiluo:Qiluo123@127.0.0.1:3306/qiluoopen")}}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
connect_timeout: 5000
# Set the idle duration before closing a connection.
idle_timeout: 500
# Minimum number of connections for a pool.
min_connections: 1
# Maximum number of connections for a pool.
max_connections: 1
# Run migration up when application loaded
auto_migrate: true
# Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_truncate: false
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_recreate: false
# Application logging configuration
logger:
# Enable or disable logging.
enable: true
# Enable pretty backtrace (sets RUST_BACKTRACE=1)
pretty_backtrace: true
# Log level, options: trace, debug, info, warn or error.
level: trace
# Define the logging format. options: compact, pretty or json
format: compact
# By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries
# Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters.
# override_filter: trace
log_file_cache: true
log_dir: data/log
file_name: app_log
cache:
# Cache type, options: redis, memory
cache_type: redis
namespace: qiluo
pool_size: 12
# Queue Configuration
url: {{ get_env(name="REDIS_URL", default="redis://127.0.0.1") }}
# Mailer Configuration.
mailer:
# SMTP mailer configuration.
smtp:
# Enable/Disable smtp mailer.
enable: false
# SMTP server host. e.x localhost, smtp.gmail.com
host: smtp.163.com
# SMTP server port
port: 465
# Use secure connection (SSL/TLS).
secure: true
auth:
user: xxx@163.com
password: xxx
# Authentication Configuration
auth:
# JWT authentication
jwt:
# Secret key for token generation and verification
secret: arxWd8PStcwb0jyRBENMQVE4Mn6T89Sl
# Token expiration time in seconds
expiration: 604800 # 7 days
# genid
snowgenera:
# 机器ID
machine_id: 1001
# 机器节点
node_id: 1
system:
# 超级管理员账号ID列表
super_role:
- 1
数据库迁移
# 方式一:使用 sea-orm-cli
cargo install sea-orm-cli
sea-orm-cli migrate up
# 方式二:若项目内含 migration 子包
cargo run -p migration
启动后端
cargo run
启动前端
# 安装依赖
pnpm i
# 配置开发环境变量:.env.development
# VITE_API_BASE_URL="http://127.0.0.1:8080"
# 启动
pnpm run dev
# 打开 http://127.0.0.1:5173
常见问题
- 缺少 OpenSSL(Linux):sudo apt-get install -y pkg-config libssl-dev
- 数据库连接失败:检查连接串、数据库是否创建、用户权限是否正确
- 端口冲突:调整 app.addr(后端)或 Vite 端口(前端)
- Windows 编译异常:优先考虑 WSL2 或安装 MSVC 构建工具