Self-Hosting a Blog for Cheap and Lazy Devs

栏目: IT技术 · 发布时间: 5年前

内容简介:So you want to start a blog? And are cheap, lazy, and generally worthless? That makes two of us. At the end of this tutorial (10 minutes tops), you’ll have a functioningNote: this tutorial assumes that you own a domain, and that you have access to a VPS. I

So you want to start a blog? And are cheap, lazy, and generally worthless? That makes two of us. At the end of this tutorial (10 minutes tops), you’ll have a functioning Ghost blog protected by HTTPS, courtesy of Caddy .

Note: this tutorial assumes that you own a domain, and that you have access to a VPS. I know, I know, VPSs aren't free, but you can get one for $2.50 per month at Vultr . So we'll let it slide. You'll also need to set up your Domain Registrar to point to your VPS provider. The gist is that you'll point your registrar to the nameservers of the VPS provider , and then you'll create an A record for your site .

Cool, let's start.

Step One: Install docker

First things first, we'll need to get docker and docker-compose set up. I'm using Ubuntu on Digital Ocean , but I'm sure you can find another easy setup guide with some Googling. Validate that docker was installed correctly with docker --version , and then we'll move on to docker-compose .

Install it with the following commands:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

and validate by running docker-compose version .

Step Two: Set up your configs

Now that we've got Docker running, let's go ahead and set up our docker-compose.yml .

Mine looks like the following:

version: '3.3'
services:
  ghost:
    image: ghost:${GHOST_IMAGE_TAG:-3.2.0-alpine}
    restart: always
    ports:
      - "2368:2368"
    expose:
      - "2368"
    environment:
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: MY_SECRET_PASSWORD
      database__connection__database: ghost
      url: https://sphuff.com

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: MY_SECRET_PASSWORD

Obviously you'll need to replace the domain and password fields with your own, but the rest should be good to go.

If you run docker-compose up , you should see the Docker images being pulled, and the Ghost blog being set up.

Next, we'll set up the Caddyfile , which will work as a reverse proxy to our ghost server. Mine looks like so:

sphuff.com {
	reverse_proxy 127.0.0.1:2368
}

www.sphuff.com {
	reverse_proxy 127.0.0.1:2368
}

Super simple. And the best thing about it is that you can add whatever domains you want in the future in this one consolidated place. It's much better than spreading your domain configs across 10 different NGINX config files. Not to mention the fact that you get HTTPS-strict out of the box.

Step Three: Run Caddy

Just caddy run in the same directory as your Caddyfile. It's that simple. Go ahead and validate that you can see your Ghost blog by navigating to https://your-site.com .

Now that we are seeing the site, we need to make sure that it continues to be served if your VPS reboots. To do so, we'll need to run Caddy in daemon mode like so:

mv Caddyfile /etc/caddy # move our Caddyfile to make it the default

systemctl start caddy # start up Caddy in deamon mode
systemctl enable caddy # enable Caddy to run on boot

And that's that.

This is my first blog post, so if you find any glaring errors, give me a shout at stephen.huffnagle@gmail.com . Or if you want to shout about something.

Thanks for reading!


以上所述就是小编给大家介绍的《Self-Hosting a Blog for Cheap and Lazy Devs》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

安全测试指南(第4版)

安全测试指南(第4版)

OWASP基金会 / 电子工业出版社 / 2016-7-1 / CNY 89.00

软件安全问题也许是这个时代面临的*为重要的技术挑战。Web应用程序让业务、社交等网络活动飞速发展,这同时也加剧了它们对软件安全的要求。我们急需建立一个强大的方法来编写和保护我们的互联网、Web应用程序和数据,并基于工程和科学的原则,用一致的、可重复的和定义的方法来测试软件安全问题。本书正是实现这个目标的重要一步,作为一本安全测试指南,详细讲解了Web应用测试的“4W1H”,即“什么是测试”、“为什......一起来看看 《安全测试指南(第4版)》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

html转js在线工具
html转js在线工具

html转js在线工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具