使用docker-compose搭建个人博客网站solo

x33g5p2x  于2022-06-16 转载在 Docker  
字(2.0k)|赞(0)|评价(0)|浏览(538)

solo是一款开源的个人博客网站

官网的地址:
https://b3log.org/solo/

搭建步骤

开通一台云上的机器

准备一个域名指向这台机器的外网IP

准备docker-compose和docker环境

没有docker和docker-compose的环境的,可以根据自己的操作系统,准备好对应的环境

准备solo目录,将需要的文件都放在这个目录下

准备docker-compose.yml 文件

version: "2"

services:
  mysql:
    container_name: mysql
    image: mysql:5.7
    restart: always
    volumes:
      - ./mysql/data:/var/lib/mysql
      - ./mysql/init:/docker-entrypoint-initdb.d
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "6603:3306"
    environment:
      MYSQL_ROOT_PASSWORD: "adminadmin"
      TZ: "Asia/Shanghai"
    command: --max_allowed_packet=32505856
  solo:
    container_name: solo
    image: b3log/solo:latest
    restart: always
    ports:
      - "8080:8080"
    environment:
      RUNTIME_DB: "MYSQL"
      JDBC_USERNAME: "root"
      JDBC_PASSWORD: "adminadmin"
      JDBC_DRIVER: "com.mysql.jdbc.Driver"
      JDBC_URL: "jdbc:mysql://mysql:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC"
    command: --listen_port=8080 --server_port=80 --server_scheme=http --server_host=taotao-java.com
  nginx:
     container_name: nginx
     image: nginx:latest
     restart: always
     ports:
       - "80:80"
     volumes:
       - "./nginx/conf:/etc/nginx/conf.d"
       - "./nginx/www/:/var/www/"

准备mysql目录下的文件

CREATE DATABASE  `solo` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
grant all PRIVILEGES on *.* to root@'%' identified by 'adminadmin';
flush privileges;

准备Nginx文件

gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied   expired no-cache no-store private auth;
gzip_disable   "MSIE [1-6]\.";

server_tokens off;
access_log off;

server {
  server_name solo.geexek.com;
  listen 80;
  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_pass http://solo:8080;
  }
  access_log  /etc/nginx/conf.d/geexek.com.log;
}

使用docker-compose启动服务

docker-compose -f docker-compose.yml up -d

查看log日志

docker logs -f solo

使用域名验证访问

http://solo.geexek.com

相关文章