0x00 安装Docker

略,见官网

0x01 下载镜像

仓库地址

# 执行命令下载镜像
# 文章发布时的版本:3.40.1
docker pull ghost:latest

0x02 配置文件准备(config.production.json)

{
  "url": "你的域名",
  "server": {
    "port": 2368,
    "host": "0.0.0.0"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost.db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

0x03 启动服务

# 建议保存成脚本
docker run \
    --name blog \
    -d \
    -v [数据保存的真实路径]:/var/lib/ghost/content \
    -v [配置存储的真实路径]/config.production.json:/var/lib/ghost/config.production.json \
    -p [机器中真实的端口]:2368 ghost:latest

访问http://[ip]:[port]即可访问博客首页

0x04 配置Nginx

server {
    listen        443;
    listen        [::]:443;
    server_name   你的域名;
    ssl on;
    ssl_certificate        你的证书文件;
    ssl_certificate_key    你的证书的key文件;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    location / {
        proxy_pass        http://127.0.0.1:你的ghost端口/;
        proxy_redirect    off;
        proxy_set_header  X-Forwarded-Proto $scheme;
        proxy_set_header  Host    $http_host;
        proxy_set_header  X-Real-IP    $remote_addr;
        proxy_set_header  X-Forwarded-For    $proxy_add_x_forwarded_for;
    }
}

0x05 enjoy it

  • https://你的域名(博客主页)
  • https://你的域名/ghost(后台管理页面)