Hello everyone, I am the second brother!

On January 1, 2022, the website of the second brother “The Path to Java Programmer Advancement” was finally launched! After 10 days, the website has broken through 1000 PU without the support of SEO, which is a small milestone.

You can try it on the following website:

tobebetterjavaer.com

Not only will you be able to call this site as beautiful as HHH, but you’ll also learn how to build a personal learning site from zero to one.

If you are a regular user of GitHub, you should have noticed that my second brother’s “The Path to Java Programmer Advancement” continues to dominate the list recently and is still on GitHub’s weekly list today.

This is the last little surprise for the 2021-2022 season.

The original Java Programmer’s Path was hosted on cloud Pages, which had no way of customizing domain names, making it difficult for users to access the site directly.

Yards cloud Pages: itwanger. Gitee. IO/tobebetterj…

How to solve this problem?

.

Let me first to lay the groundwork for you this code cloud Pages is how to service, understand the situation, we will be easy to think of a solution.

First, the source of the Java Programmer Progression column is an open source repository on GitHub.

GitHub address: github.com/itwanger/to…

In addition to the MD documentation and images, there are code samples, as well as the base environment files for Docsify.

  • Index.html entry file
  • Readme. md will be rendered as the home page content
  • Nojekyll prevents GitHub Pages from ignoring files starting with an underscore
  • _sidebar. Md will be rendered as sidebar content
  • _coverPage. md will be rendered as cover art

Docsify is an amazing document site generator that, unlike GitBook and Hexo, does not generate static.html files and all conversion takes place at run time. All you need is an index.html file and some basic configuration files to get started writing documentation, hosted directly on GitHub Pages (saving the server money).

However, due to GitHub’s network access, I synchronized my Java Programmer Progression column to the code cloud and replaced GitHub Pages with the code cloud Pages, which provided much faster network access.

Code cloud address: gitee.com/itwanger/to…

Meanwhile, code cloud Pages also supports static sites such as Jekyll, Hugo, Hexo and Docsify. When the GitHub repository is updated, you can click the Refresh icon on GitHub Pages to immediately complete the service synchronization.

You can access the Path to Java Programmer Advancement web site at the url provided by code Cloud Pages.

But for a variety of reasons, code cloud Pages did not provide self-defined domain name + HTTPS service, Pro version support, but also because of business adjustment, closed the purchase entrance of individual users.

This is ridiculous.

Solution 1

This is the easiest solution, and the dumbest: upload a local repository to a cloud server and deploy a static web site via Nginx.

Before uploading the server, let’s make sure that the local docsify directory is complete. So we need to run the Docsify service locally.

Go to the repository directory of the local Java Programmer’s Path and execute Docsify Serve to start the service.

Visit http://localhost:3000 in the browser address bar:

I can confirm that there is no problem.

Then upload the local files to the cloud server and deploy the static site through Nginx.

However, there is a serious problem with this, which is that there is no synchronization between the cloud server and the local, GitHub repository.

Solution 2

This is a more complete solution: set up a Git repository on the server, pull it from GitHub, and deploy a static site via Nginx.

This makes it easy to solve the problem of out-of-sync between repositories, because the GitHub repository must be the official version and the latest version, which is the most convenient and secure to pull from. Some testing is done locally, such as tweaking the configuration of Docsify, which is not suitable for cloud server pull.

Git environment setup, I in the “Java Programmer advanced path” column “Git” has been explained in detail.

I’m going to show you a little bit about the setup process.

First, install Git

You can run the yum install git command on CentOS to install the Git environment.

Second, initialize Git

Run git init to initialize the Git directory.

Step 3: Clone GitHub repository to cloud server

To convince GitHub that all operations are “you”, you need to configure the SSH key before cloning. For details, see: Crash! Interns made a mess of the team’s code repository… The “Remote Repository” section of this article.

I’m not going to do it here.

Click the “Code” menu on the GitHub repository to copy the SSH address.

Then run the git clone command to pull the latest content from the remote repository.

Step 4, deploy a static web site through Nginx

Nginx is ideal for deploying static web sites by setting the server’s access directory to an index.html file.

OK, this time to visit the domain name https://tobebetterjavaer.com can see “the road to Java programmers advanced, content.

With this solution, synchronization between the local, GitHub, and cloud servers is complete.

When there are updates on GitHub, pull them to the cloud.

For example, we modified the _sidebar. Md file in the GitHub repository of the Java Programmer’s Path to Advancement column to append an exclamation mark.

There are two ways to pull.

First, execute git fetch and then git merge.

9909f82.. 7f4b815 Master -> origin/master

The second option is to execute git pull directly.

However, this is not perfect. Every time there is an update on GitHub, you have to manually pull the update from the cloud server. Can you automate it?

You can add a Shell script using the scheduled task in the Pagoda panel.

The script content is very simple, just two lines:

CD # switch to the git directory/home/WWW/git/toBeBetterJavaer # git command git pullCopy the code

Let’s save it and let’s test it.

We have modified the _sidebar. Md file in GitHub warehouse of “The Way to Advance Java Programmers” column, and changed the Exclamation mark in Chinese to the Exclamation mark in English.

Click the “Execute” button for the scheduled task.

Check whether files on the cloud server have changed.

So far, we have completed the migration of the website from code cloud Pages to VPS (Virtual Private Server, Virtual private Server).

Finally, add a total number of visits and total number of visitors to the website with you to see how many PV of “The Way to Java Programmer Advancement” a month later.

< script async SRC = "/ / busuanzi. Ibruce. Info/busuanzi / 2.3 / busuanzi. Pure. The mini. Js" > < / script > < span Id ="busuanzi_container_site_pv"> Total number of visits to this site <span ID ="busuanzi_value_site_pv"></span> Times </span>Copy the code

Two lines of code, one to import the JS file and one to display the data.

Refresh the web page, found already have ha, I was the first.

Then, can put the lot/yards cloud preview link Pages to modify the code cloud for https://tobebetterjavaer.com.

A simple summary: in order to build this website, it is really able to learn a lot of practical knowledge, such as:

  • The HTTP was upgraded to HTTPS
  • Nginx configures static resources
  • Domain name resolution
  • SSL Certificate Generation
  • Basic use of Git
  • Basic use of pagoda panel
  • Basic use of Tabby terminal
  • The domain name registration
  • Etc., etc.

If you have time, I strongly suggest you to take a ride, especially if you have passed ali Cloud server for free, you will really learn the actual combat experience after taking a hand.

In 2022, the second brother will continue to produce more high-quality original works and enrich the content of “The Way to Advanced Java Programmers”. I hope this column will become everyone’s first choice to learn Java in the future!


This post has been adapted to GitHub’s 1.0 K + Star open-source column, “The Path to Java Programmer Advancement”. This column is humorous, easy to understand, and extremely friendly and comfortable for Java enthusiasts 😄, The content includes but is not limited to Java foundation, Java Collection framework, Java IO, Java concurrent programming, Java virtual machine, Java enterprise development (Git, SSM, Spring Boot) and other core knowledge points.

Star the repository to become a better Java programmer. You can click the link below to jump to star and witness this exciting moment.

Github.com/itwanger/to…

This column is still listed in GitHub Trending (weekly list of Java), which makes the second brother finally feel the happiness of topping the list!

Nothing keeps me here but purpose, and though there are roses by the shore, and trees by the shore, and still harbours, I am not tied.

We’ll see you next time