准备

域名
xgnote.com
服务器
腾讯云cvm1c1g2m Debian 9 strach

环境配置

安装docker

curl https://releases.rancher.com/install-docker/17.03.sh | sh

配置加速器

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
sudo systemctl restart docker.service

配置防火墙

#开放22、80、443端口
sudo apt install ufw
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable

安装

安装docker ghost

  1. 数据持久化在/srv/site文件夹
  2. ghost版本为2.9.1
sudo mkdir /srv/site
sudo docker run --name ghost \
 -p 127.0.0.1:2368:2368 \
 -e url=https://xgnote.com \
 -v /srv/site/:/var/lib/ghost/content \
 --restart=always \
 -d ghost:2.9.1

安装配置nginx

sudo apt install nginx

修改 /etc/nginx/sites-available/default

server {
	listen 80;
	server_name xgnote.com;
    #将http访问重定向到https
	location / {
		return 301 https://$server_name$request_uri;
	}
}

server {
	server_name xgnote.com;
	listen 443 ssl;

	location / {
        proxy_pass	http://127.0.0.1:2368;
        proxy_set_header    X-Real-IP $remote_addr;
	    proxy_set_header    Host      $http_host;
		proxy_set_header X-Forwarded-Proto https;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

	}
    #指定ssl验证文件位置
	ssl_certificate     /etc/certs/1_xgnote.com_bundle.crt;
	ssl_certificate_key /etc/certs/2_xgnote.com.key;
	ssl on;

}

将nginx加入开机启动

sudo systemctl enable nginx
sudo systemctl start nginx