Portal: Halo website

I am Xiao Bai, a freshman this year. I just got out of the hardships of mathematics, physics and chemistry, and found that I have a strong interest in learning computer. During the learning process, I found many interesting things, such as the open source operating system Linux, which I just got to know. Windows is the only operating system

At the same time, I unlock another attribute, which is “torment”. I like to find open source and easy to use software to replace the software I am using. Of course, in this process, I also found many very practical tools, such as Typora for taking notes and VeraCrypt for encrypting small movies

With more and more notes, more and more records, I want to find a place to share with others, the need is to build their own blog system

Of course, now there are many excellent open source blog systems, there are many choices, such as Hexo, VuePress, and so on. Finally, I chose Halo based on SpringBoot development. Its source code is not very complex, but the code is very standard, for Java developers, especially Java beginners, There’s a lot to learn


How easy to deploy Halo as a SpringBoot app is to get it up and running with just two lines of commands:

The premise for this to work is that the machine has the necessary environment, such as JDK, configured

$Wget HTTP: / / https://dl.halo.run/release/halo-1.4.8.jar
$Java jar halo - 1.4.8. Jar
Copy the code

Of course, the most convenient way to deploy is Docker

$ docker pull halohub/halo:latest
$ docker run -it -d --name halo -p 8090:8090 -v ~/.halo:/root/.halo halohub/halo:latest
Copy the code


Halo is also a very convenient place to move your blog. All of your custom configurations, themes, and so on are stored in the ~/. Halo directory. When you want to move your blog, just back up the folder and run the above command again. Background management system also provides backup and restore function, the principle is the same


Some graphic effects:


How to deploy

It is recommended to use the Docker method for deployment, which is simple and convenient

Besides Halo also supports a key deployment to tencent cloud CloudBase | Halo Documents, but I haven’t tried this, do not recommend that anyone interested in can try to use this way to deploy

As a dynamic SpringBoot-based blogging system, Halo cannot run without server resources. Static page blogging systems such as Hexo and VuePress can be deployed on hosting services such as GitPage and GiteePage, with no server overhead. There is no time cost of operation and maintenance, so how to choose the specific or depends on the individual


steps

1. Server leasing

To deploy a blogging system, you first need a server with an external IP so that others can access your blog

Of course, there are other options, such as deploying on your machine, then enabling Intranet penetration, and then buying a domain name for reverse proxy, which is also accessible to others, but only if your machine is turned off

Can choose a lot of servers, Huawei cloud, Tencent cloud, Ali cloud are all available, how to lease and buy a domain name here is not repeated

If you have a cloud server, IP is 1.2.3.4, and connected through SSH tool, by the way, recommend a Windows SSH tool: Termius, if you are Mac/Linux, directly use the terminal is more convenient


2. Docker environment configuration

The commands are different for different Linux distributions, but let’s say you buy a server that runs Centos7

Make sure to open the firewall port on your server. Halo runs at 8090 by default. Open 80 if you are using a domain name and 443 if you want to configure Https

If you are running on a virtual machine, it is also necessary to open the port and handle SeLinux, both of which cause pages to be inaccessible after the service is started


Add the software source and install Docker

$ curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
$ yum install docker-ce
Copy the code

After executing these two commands, you are ready to deploy

$ docker pull halohub/halo:latest
$ docker run -it -d --name halo -p 8090:8090 -v ~/.halo:/root/.halo halohub/halo:latest
Copy the code

Wait for some time, wait for the service to complete the official startup can access

Assume that the external IP address of this server is 1.2.3.4, then open the browser, input 1.2.3.4:8090 can open the initialization page, according to the prompt initialization can be happy to use


3. Configure a user-defined domain name

Assume that the purchased domain name is www.abc.com. An important step is domain name resolution, which is to register the mapping between your domain name and IP address in the DNS server. When the user accesses the domain name with a browser, the DNS server will resolve the actual IP address

Tutorial Portal -> Domain resolution Settings


4. Set the reverse proxy

The reverse proxy can be Nginx or Caddy, with Nginx chosen here

Install && start

$ yum install nginx
$ systemctl enable nginx
$ systemctl start nginx
Copy the code

Add custom configuration vim/etc/nginx/conf., d/a halo. Conf

You just need to change the two lines that are commented out

Upstream halo {server 127.0.0.1:8090; } server { listen 80; listen [::]:80; server_name www.abc.com; # Client_max_body_size 1024m; location / { proxy_pass http://halo; http://127.0.0.1:8090 proxy_set_header HOST $HOST; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }}Copy the code

You can also add this section directly to /etc/nginx/nginx.conf


Restart the Nginx

$ systemctl restart nginx
Copy the code

To access Halo normally, visit www.abc.com


If you found this article helpful, or have questions, suggestions, etc., feel free to leave a comment