Chase Mao's blog

Blog Building From Zero (1) Resouces: VM, and Domain

2024-06-09

Preface

I have always wanted to build a self blog, as a deveolper, it is like one of the must do things.

Finally, I decided to do it and it took me two week’s spare time to fully build it. And now I just need to push a new article to my private git repository. It will automatilly pulled by two different vms, and this two vm will server blog for clients together.

I’d like to share how I built blog from scratch to a full stack distributed application.

In this first part, I will introduce how to prepare resources we need to build a blog.

VM

First we need a vm, why and what is a vm?

Lets review some background of how a blog is built up. When we browse a blog, what actually happen is we sent a requset via Internet to some other machine. And that machine return the data of the blog website, so the page will display in the browser. So we need a machine to handle the request, or it is called server too. It is a basic Client-Server model like below.

Client —->(send request)—-> Server

Client <—(recive response)<—Server

So as it mentioned, we need machine to handle request and send back response.

Cloud provider sell machine we need, and most of them is virtual machine (VM). vm is like a real machine, and it is deprived from a real machine. The cloud provider’s real machine have a lot of cpu and memory. In order to sell them efficiently, clound provider will seperate resouce into many virtual machine which is bind with a few resources like 2 cpu and 4 GB memory. After all virtual machine is like a real machine for us.

What we really need to do is buy virtual machine from cloud provider. And I bought from Tencent Cloud.

Like the image, I applied a Ubuntu 20.04 LTS VM.

The detailed process of buying a VM will be dismissed. Because different cloud provider have different porcess. Anyhow it is not difficlut, follow the guide of the cloud provider which you choose.

After vm is prepared, we can use ssh to connect to the terminal of vm.

Domain

After got a vm, we need a domain. Still why and what is a domain.

Domain is a string that in the broswer’s address bar. We need to pick a proper domain for the blog. So when others put the blog domain into browser, they can reach the blog.

And there is import process in it called DNS (domain name search). The DNS process will convert the domain into a ip address. Why so? Because the machine interact with each other via their ip address on the Internet. As we mentioned before, when someone browse the blog. They will fetch data from the vm where we deploy our blog server. In order to make others got our server correctly, the need to convert the blog domain into the correct ip of the vm we applied.

After all, what we should do is to buy a domian. And add a resolution record in it. For example, I bought a domain (chasemao.com) from Tencent. And I add a resolution record in it. The IP address is the vm we just applied.

If everything works well, when we ping the domain we should find the IP address we just added like this.

1
2
3
4
5
$ ping chasemao.com
PING chasemao.com (43.134.28.24) 56(84) bytes of data.
64 bytes from sg-VM-0-8-ubuntu (43.134.28.24): icmp_seq=1 ttl=64 time=0.049 ms
64 bytes from sg-VM-0-8-ubuntu (43.134.28.24): icmp_seq=2 ttl=64 time=0.069 ms
64 bytes from sg-VM-0-8-ubuntu (43.134.28.24): icmp_seq=3 ttl=64 time=0.062 ms

Summary

We already got the resouces for building blog. In the next part Blog Building From Zero (2) Basic Server: HTTP, HTTPS, and Nginx, we will dicuss how build basic server.