前提
具体操作可参考Docker + Halo(1.5.4) + Nginx:https://blog.shihd.cn/archives/docker-halo-1.5.4-nginxda-jian-ge-ren-bo-ke
环境差异
Docker(CE):23.0.0
Halo:2.2.0
MySQL:8.0.31
Nginx:1.14.1
未提及部分和1.5.4版一致
部署差异
Nginx独立,不再使用Docker
取消Redis
Nginx
安装
yum -y install nginx
修改blog.shihd.cn文件
# 旧
proxy_pass http://halo_server:8090;
# 新,因为独立于Docker了,所以不能用容器名
proxy_pass http://127.0.0.1:8090;
校验配置文件
nginx -t
# 输出以下类似信息及代表OK
# nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
# nginx: configuration file /etc/nginx/nginx.conf test is successful
docker-compose.yaml
version: "3"
services:
halo:
image: halohub/halo:2.2.0
container_name: halo
restart: on-failure:3
depends_on:
halodb:
condition: service_healthy
networks:
halo_network:
volumes:
- ./halo:/root/.halo2
ports:
- "8090:8090"
command:
- --spring.r2dbc.url=r2dbc:pool:mysql://halodb:3306/halo?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
- --spring.r2dbc.username=root
- --spring.r2dbc.password=替换成自己的数据库密码
- --spring.sql.init.platform=mysql
- --halo.external-url=替换成自己的域名
- --halo.security.initializer.superadminusername=替换成自己的超管账号
- --halo.security.initializer.superadminpassword=替换成自己的超管密码
halodb:
image: mysql:8.0.31
container_name: halodb
restart: on-failure:3
networks:
halo_network:
command:
- --default-authentication-plugin=mysql_native_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
- --explicit_defaults_for_timestamp=true
volumes:
- ./mysql:/var/lib/mysql
- ./mysqlBackup:/data/mysqlBackup
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 3s
retries: 5
start_period: 30s
environment:
- MYSQL_ROOT_PASSWORD=替换成自己的数据库密码
- MYSQL_DATABASE=halo
- TZ=Asia/Shanghai
networks:
halo_network:
启动
docker-compose up -d
访问后台
浏览器输入:https://域名/console
参考资料
Halo
评论区