侧边栏壁纸
  • 累计撰写 42 篇文章
  • 累计创建 82 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

Docker Compose 构建Halo博客

Even
2022-09-01 / 0 评论 / 0 点赞 / 601 阅读 / 387 字 / 正在检测是否收录...

Docker Compose 构建Halo博客

一、下载Halo配置

1. 创建工作目录

mkdir ~/.halo && cd ~/.halo

2. 下载示例或创建空白文件

wget https://dl.halo.run/config/application-template.yaml -O ./application.yaml
# or
touch application.yaml

3.修改配置文件

server:
  port: 8090

  # Response data gzip.
  compression:
    enabled: false
spring:
  datasource:

    # 使用MySQL配置
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://halodb:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
    username: root
    password: nihao123

halo:

  # Your admin client path is https://your-domain/{admin-path}
  admin-path: admin

  # memory or level
  cache: memory

二、构建项目

1. 创建docker-compsoe文件

mkdir docker-compose.yaml

2. Vim编辑

version: "3.9"
    
services:
  halodb:
    image: mysql:5.7
    container_name: even_halo_mysql
    volumes:
      - /usr/local/docker/mysql/conf:/etc/mysql
      - /usr/local/docker/mysql/logs:/var/log/mysql
      - /usr/local/docker/mysql/data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: nihao123
    
  halo:
    depends_on:
      - halodb
    image: halohub/halo:1.4.17
    container_name: even_halo_blog
    volumes:
      - ~/.halo:/root/.halo
    ports:
      - "8090:8090"
    restart: unless-stopped

3. 构建

docker compose up -d

三、创建数据库

1. 进入到mysql容器

docker exec -it even_halo_mysql /bin/bash

2. 修改远程连接密码

use mysql;
grant all privileges on *.* to root@'%' identified by "nihao123";
flush privileges;

3. 创建库

create database halodb character set utf8mb4 collate utf8mb4_bin;

四、安装配置

# 访问8090端口即可安装
http://ip:8090

五、配置nginx反向代理

1. 修改conf文件

upstream halo {
  server 127.0.0.1:8090;
}
server {
  listen 80;
  listen [::]:80;
  server_name www.yourdomain.com;
  client_max_body_size 1024m;
  location / {
    proxy_pass http://halo;
    proxy_set_header HOST $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

2. 使用 OneinStack 安装 Nginx

0

评论区