前言
本人的个人博客站点(https://www.darkathena.top )基于Halo博客系统搭建,该博客系统后端可以配置多种数据库,默认为H2,但是最新版已不建议使用H2,而是建议使用mysql/postgresql等数据库。经验证,MogDB数据库也可以作为Halo博客系统的后端数据库。
一、数据库部分
- 安装MogDB数据库 (可参考MogDB官方文档)
- 修改参数 password_encryption_type=0 ,并添加pg_hba规则 host all all 0.0.0.0/0 md5
- 重启数据库
- create database halo dbcompatibility ='PG';\c halo
- create user halo password 'Halo@123' ;
二、Halo部分
- 在服务器创建目录
mkdir ~/halo
cd ~/halo
- 编写docker-compose.yaml 文件
version: "3"
services:
halo:
image: halohub/halo:2.12
container_name: halo
restart: on-failure:3
network_mode: "host"
volumes:
- ./halo2:/root/.halo2
privileged: true
command:
# 修改为已有的 MogDB 配置
- --spring.r2dbc.url=r2dbc:pool:postgres://xxx.xxx.xxx.xxx:26000/halo
- --spring.r2dbc.username=halo
- --spring.r2dbc.password=Halo@123
- --spring.sql.init.platform=postgresql
# 外部访问地址,请根据实际需要修改
- --halo.external-url=http://localhost:8090/
# 端口号 默认8090
- --server.port=8090
- 启动
docker-compose up -d - 查看启动日志
docker-compose logs -f
三、完成
- 打开halo ,进行初始化设置
http://xxx.xxx.xxx.xxx:8090/
四、相关链接
- Halo官网 https://www.halo.run/
- Halo安装文档 https://docs.halo.run/getting-started/install/docker-compose
- MogDB官网 https://mogdb.io/
- MogDB安装文档(PTK) https://docs.mogdb.io/zh/ptk/v1.1/quick-start