MENU

#笔记#如何用docker搭建ghost博客

April 22, 2019 • Read: 1036 • 网络笔记

使用docker搭建ghost博客是一件很快乐的事情,因为ghost备份是很方便的事情,这也是为什么我会选择使用docker进行安装ghost博客。其中涉及到几个知识点。docker的安装。那么进行下一步。

我们需要什么

  • 1GB内存以上的VPS
  • ssh链接工具
  • 如何出现问题熟练搜索引擎

安装docker

centos安装docker

yum update
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
systemctl start docker

Debian安装docker

apt update
apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt update
apt-cache policy docker-ce
#进行上述操作后会出现如下输出
docker-ce:
  Installed: (none)
  Candidate: 18.06.1~ce~3-0~debian
  Version table:
     18.06.1~ce~3-0~debian 500
        500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
apt install docker-ce
systemctl status docker

拉取镜像

docker pull ghost

运行ghost-docker

docker run --name ghost --restart=always -e url=http://mydomain.com -v /mnt/docker/ghost:/var/lib/ghost/content -p 8080:2368 -d ghost #将http://mydomain.com替换成自己的域名

安装NGINX

因为本次操作使用测试的是Debian9系统,另,你也可以使用oneinstack进行安装nginx

NGINX配置文件

server {

listen 80;

server_name 你自己的域名;

location / { proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $http_host;

proxy_pass http://127.0.0.1:8080;

      }

}

上述是没有SSL的NGINX配置,如果想要网站加上小绿锁你可以使用Oneinstack进行自动续签,当你修改自己的NGINX配置的时候,只需要注意将完整的拷贝进去。

location / { proxy_set_header X-Real-IP $remote_addr;
    
    proxy_set_header Host $http_host;
    
    proxy_pass http://127.0.0.1:8080;
    
          }
    
    }

重启nginx service nginx restart

访问你的域名,搞定~

ghost-docker文件储存的地方

docker的文件储存在/var/lib/docker

Archives QR Code Tip
QR Code for this page
Tipping QR Code
Leave a Comment

已有 1 条评论
  1. Fay Fay

    大神,你好,全新的小白,到安装nginx就看不懂了,请问往下改如何去进行?
    我已经用docker拉取了nginx,然后改怎么做呢?