B3log开源博客compose搭建

Python微信订餐小程序课程视频

https://blog.csdn.net/m0_56069948/article/details/122285951

Python实战量化交易理财系统

https://blog.csdn.net/m0_56069948/article/details/122285941

B3log开源博客搭建

docker 安装

yum install docker-ce-17.12.1.ce

docker-compose 安装

curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

# 设置 docker-compose 执行权限
chmod +x /usr/local/bin/docker-compose

注意

  • 事先购买好域名并配置好解析。
  • 开放服务器80和443端口,云服务器在安全组中添加规则。
  • 证书申请在SSL证书,我是用的阿里云服务器,证书可以免费使用一年,过期后需要重新申请。

项目结构

.
├── compose-nginx.yml
├── compose-solo-mysql.yml # 这里我是自建的数据,之前有,就没有执行这个编排文件
├── docker-compose.yml
├── nginx
│   ├── cert # https使用
│   │   ├── 7620436_www.example.com.key
│   │   ├── 7620436_www.example.com.pem
│   ├── conf
│   │   └── app.conf
│   └── logs
│       ├── access.log
│       └── error.log
├── solo
│   └── skins # 博客皮肤,可以从官方仓库克隆项目,复制里面的skins

温馨提示:下面的配置请根据这个目录结构对号入座,本人主站也是使用该配置部署。有问题请评论区联系我。

docker-compose.yml

version: "3"

services:
  solo:
    container\_name: solo
    image: b3log/solo
    restart: always
    environment:
      RUNTIME\_DB: "MYSQL"
      JDBC\_USERNAME: "root"
      JDBC\_PASSWORD: "123456"
      JDBC\_DRIVER: "com.mysql.cj.jdbc.Driver"
      JDBC\_URL: "jdbc:mysql://172.16.96.61:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"
    command: --listen\_port=8080 --server\_scheme=https --server\_host=www.example.com --lute\_http=http://172.16.96.61:8249 --server\_port= --static\_server\_scheme=https --static\_server\_host=cdn.jsdelivr.net --static\_path=/gh/88250/solo/src/main/resources
    volumes:
      # Pay attention to synchronization time
      # echo 'Asia/Shanghai' > /etc/timezone/timezone
      - /etc/timezone/timezone:/etc/timezone
      - /etc/localtime:/etc/localtime
      - ./solo/skins/:/opt/solo/skins/:ro
    ports:
      - 8080:8080
    dns:
      - 114.114.114.114
      - 8.8.8.8
  lute:
    image: b3log/lute-http
    container\_name: lute
    restart: always
    volumes:
    # Pay attention to synchronization time
    # echo 'Asia/Shanghai' > /etc/timezone/timezone
    - /etc/timezone/timezone:/etc/timezone
    - /etc/localtime:/etc/localtime
    ports:
    - 8249:8249

compose-solo-mysql.yml

version: "3"
services:
  blog-mysql:
    image: mysql:8.0.22
    restart: always
    container\_name: blog-mysql
    privileged: false
    ports:
      - 3306:3306
    networks:
      - blog-extranet
    environment:
      - MYSQL\_ROOT\_PASSWORD=123456
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./mysql/conf/:/etc/mysql/
      - ./mysql/data/:/var/lib/mysql/
      - ./mysql/init/:/docker-entrypoint-initdb.d/
      - ./mysql/logs/:/logs/

networks:
  blog-extranet:
    driver: bridge

compose-nginx.yml

version: "3"

services:
  nginx:
    image: nginx:1.14
    restart: always
    container\_name: nginx
    privileged: true
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./nginx/conf/:/etc/nginx/conf.d/
      - ./nginx/cert/:/etc/nginx/cert/
      - ./nginx/logs/:/etc/nginx/log/
    dns:
    - 114.114.114.114
    - 8.8.8.8
networks:
  blog-extranet:
    driver: bridge

app.conf (nginx配置)

upstream blog {
    # server www.example.com:8080;
    # Solo 监听端口,这里的ip最好是你的云服务器内网ip,可以通过ip addr 或者ifconfig查看
    server  172.16.96.61:8080;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name www.example.com;
    # http 重定向到https 配置
    if ($http_x_forwarded_proto = "http") {
        return 301 https://$server_name$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name www.example.com;
    charset utf-8;
    access_log /etc/nginx/log/access.log;
    error_log /etc/nginx/log/error.log;
    
    ssl_certificate /etc/nginx/cert/7620436_www.example.com.pem;
    ssl_certificate_key /etc/nginx/cert/7620436_www.example.com.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   
    ssl_prefer_server_ciphers on;
 
    location / {
         proxy_pass http://blog$request_uri;
         proxy_set_header Host $http_host;
         proxy_set_header X-Forwarded-Host $server_name;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         client_max_body_size 10m;
    }

    # 防止爬虫抓取
    if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot")
    {
        return 403;
    }

    error_page   403 404 500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html/error-page;
    }
}

  • B3log开源博客搭建

  • docker 安装

  • docker-compose 安装

  • 注意

  • 项目结构

  • docker-compose.yml

  • compose-solo-mysql.yml

  • compose-nginx.yml

  • app.conf (nginx配置)

    __EOF__

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NVfi5zlW-1650170655545)(https://blog.csdn.net/jockming)]itwetouch - 本文链接: https://blog.csdn.net/jockming/p/16155249.html

  • 关于博主: 评论和私信会在第一时间回复。或者直接私信我。
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
  • 声援博主: 如果您觉得文章对您有帮助,可以点击文章右下角**【[推荐](javascript:void(0)】**一下。

你可能感兴趣的:(计算机,计算机)