当前位置:网站首页>[technical grass planting] cdn+ lightweight server +hugo= let the blog "cloud native"

[technical grass planting] cdn+ lightweight server +hugo= let the blog "cloud native"

2022-06-24 01:30:00 User 1435446

Building your own blog site should be one of the first romantic experiences of many programmers , Various reasons often make this romance fade away . Today I will introduce my blog solution :cdn+ Lightweight servers +hugo= Let blog “ Cloud native ” once .

How convenient is this solution ?

I'm writing this blog right now , There are only three things you need to do to publish to a website :

  1. hugo new posts/cloudnative-blog-using-tencent-cloud.md
  2. Use vscode edit markdown file
  3. bash deploy.sh

deploy.sh I wrote my own one click script , Role is :

  1. Commit current changes to github
  2. ssh To a lightweight server , Installation dependency (hugo、nginx)、git pull、 Use hugo Generate static blogs 、nginx reload.

Don't be shell The script scared ,deploy.sh It's very simple :

#! /bin/bash

dir=$PWD
host=$([ "$1" = "" ]&& echo "yourhostname"|| echo "$1")
port=22

git pull
git add .
git commit -m "commit @arloor $(date)"
git push
if [ "$?" = 0  ]
then 
    #  Call... On the server tarloor command 
    #  The order will check httpd、hugo、 and git Warehouse , And generate static websites to nginx Of html Catalog , Realize one click website deployment 
     ssh [email protected]$host  -p$port -t "
     bash tarloor 0 # 0 Don't use agents ,1 Using agents 
     "
echo -e "\033[32m  Please visit : https://"$host"\033[0m"
else
    echo -e "\033[32m  Push failed  \033[0m"
fi

ssh To a lightweight server tarloor The command is also a shell Script , The following commands can be executed on the lightweight server to download :

# centos8、centos stream、rockylinux、almalinux Etc rpm Of Linux Distribution version 
wget -O /usr/local/bin/tarloor http://arloor.com/tarloor.sh
# ubuntu、debian Etc deb Of Linux Distribution version 
wget -O /usr/local/bin/tarloor http://www.arloor.com/tarloor_deb.sh

There is such a convenient writing and publishing environment , Blogging is fun !

hugo The fastest static website builder

hugo Our ecology is very good , There are many custom themes to choose from . The theme I choose is hyde-hyde, It's quite retro . Students can go to hugo Theme page Choose a theme , You can also directly put the github project clone Come down , hold content\posts You can have your own original blog by deleting all the articles under .

Use cdn Accelerate domestic visits

Because the lightweight server will execute git pull To github Pull the latest content from the blog , And domestic server access GitHub Speed is really pulling the crotch , I chose the server of Tencent cloud in Hong Kong .

Tencent cloud's lightweight servers in Hong Kong, China have a good domestic access speed , For the sake of stability , I still use Tencent cloud cdn Accelerated domestic visits , Just open cdn service , Then configure the origin station .

原网站

版权声明
本文为[User 1435446]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/11/20211117190418164K.html

随机推荐