Author: Xiao Fu Ge blog: https://bugstack.cn

Precipitation, share, grow, let oneself and others can harvest! ?

One, foreword

What a surprise! GitHub is under attack! It also crashed my blog using GitPage!

The whole website can not be visited, or a little panic, after all, before this did not consider that there can also be this matter. But even if you don’t have a plan in place, you can still use your own technology to get things done and recover as soon as possible. In order to restore access to the blog as soon as possible, I moved the site to the cloud’s GitPage service, turned it on for free for a month (which smells good), and quickly fixed the configuration and HTTPS. Well! It’s even faster than it was before. But then I found out that some network environments were not accessible, which made me feel bad again, otherwise I would have to pay for the cloud (90 yuan a year). To code cloud official website group asked to use this build blog, Baidu included? There was no response. I don’t have to use it if it’s not on it, right. Money spent, not done! But it’s good to have Gitee, otherwise the site wouldn’t be back up so quickly. It would take at least 24 hours if we followed the following pattern.

The next step was to move the website to a server I bought myself. Although the process was a bit bumpy, it still met my needs. Improve the speed of the website, experience, also can let the website is included by Baidu crawler. If you also have this problem or want to start a blog, you can follow my steps below to install Jekyll and deploy the blog.

Second, the version

Ruby, a simple and fast object-oriented (object-oriented programming) scripting language, was developed in the 1990s by the Japanese Yukihiro Matsumoto under the GPL and the Ruby License. It draws inspiration and features from Perl, Smalltalk, Eiffel, Ada, and Lisp. The Ruby language itself has also developed alternative Ruby languages for JRuby (Java platform), IronRuby (.NET platform) and other platforms. The author of Ruby started writing Ruby on February 24, 1993, and did not publish it publicly until December 1995 on FJ (newsgroup). Because Perl sounds the same as the June birthstone pearl, Ruby is named after the July birthstone Ruby.

The serial number website describe
1 https://rubyinstaller.org/downloads/ Ruby official website download
2 https://gems.ruby-china.com/ Full RubyGems imageChina
3 http://www.ruby-lang.org/zh_cn/documentation/ Ruby Programming Documentation
4 http://jekyllthemes.org/ Jekyll template
5 https://www.jekyll.com.cn/docs/ Quick Start Manual

There are many versions of Ruby, and there are separate installers (Ruby + DevKit), which are the most error-prone areas. Sometimes the installation and their own version of the blog is not on, and the resulting error can not be compiled. This version of Ruby+ DevKit 2.5.7-1 (x64) is more suitable for Jekyll blog compilation and deployment. If you are slow to download from the official website, you can add the official account: bugstack wormhole stack, reply to email.

Three, installation,

Ruby+ DevKit 2.5.7-1, the complete package installation process is relatively simple, but need to pay attention to the following points;

  1. Installation path do not have space, Chinese and other special symbols
  2. The options in the installation are shown in the following figure
  3. After the installation, the data sources need to be changed. These contents will be shown in the general presentation below

1. Double-click on RubyInstaller-Devkit-2.5.7-1-x64 to open the software.

2. Set paths and options

  • Attention! Never set paths with Spaces, Chinese characters, or special symbols
  • Attention! The first two are required, but the third is optional

3. Continue until completed

Click Next, no configuration changes are required

Initial installation is successful, click
Finsh

By this time our software has been installed, you can already execute the command to view the version.

Copyright (c) 2009 Microsoft Corporation. All rights reserved. All rights reserved. C:\Users\xiaofuge>ruby -v ruby 2.5.7p206 (cialisx10-01 revision 67816) [x64-mingw32]

Four, configuration,

After the installation is complete, you need to perform a number of configurations to get the software to work properly. If you don’t pay attention to the English prompt, you may uninstall the newly installed software by hitting a return!

1. The change of the source

update
Gem

C:\Users\xiaofuge>gem update --system Updating rubygems-update Fetching: RubyGems -update-2.7.0.gem (100%) Successfully installed rubyGems -update-2.7.0.install...

Check the version

C: \ Users \ xiaofuge > gem - v 2.7.7

Replace the source or you will download slowly

C:\Users\xiaofuge>gem sources --add https://gems.ruby-china.com/ --remove http
s://rubygems.org/
source https://gems.ruby-china.com/ already present in the cache
source https://rubygems.org/ not present in cache

View the new source

C:\Users\xiaofuge>gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com

2. Base installation and configuration

The following steps are relatively simple, but the whole process is time-consuming. The black window will download about 600M software after we execute the command.

Command 1

Order 2

Command 3

Good! When you successfully installed to this, your software has been installed, can use!

Install Jekyll

The Ruby software has been installed, and the next step is to install the content of our blog.

Check the version and install

E:\>gem -v 2.7.7e :\>gem install Jekyll Fetching: Public_suffix-4.0.0.gem (100%) Successfully installed public_suffix-4.0.0.fetching: Gem (100%) Successfully installed addressable-2.7.0 Fetching: gem (100%) Successfully installed addressable-2.7.0 Fetching: Gem (100%) Successfully installed colorator-1.1.0. Gem (100%) Successfully installed colorator-1.1.0... ass-converter, rb-fsevent, rb-inotify, listen, jekyll-watch, kramdown, kramdown- parser-gfm, liquid, mercenary, forwardable-extended, pathutil, rouge, safe_yaml, unicode-display_width, terminal-table, jekyll after 33 seconds 26 gems installed

View the installed version of Jekyll

E: \ > jekyll -v jekyll 4.0.0

6. Create a blog

Jekyll gives us the command to create a blog, you just need to choose your own folder address, enter the execution can be.

1. Access to local sites

C:\Users\xiaofuge>E:

E:\>cd E:\itstack

2. Create a blog

E:\>jekyll new myblog Running bundle install in E:/myblog... Bundler: Fetching source index from https://rubygems.org/ Bundler: Resolving dependencies............. Bundler: Using public_suffix 4.0.3 Bundler: Using Addressable 2.7.0... New jekyll site installed in E:/myblog. E:\>cd myblog

3. Compile the blog

You can use localhost:4000 as the default location for the localhost.

E:\myblog>jekyll build Configuration file: E:/myblog/_config.yml Source: E:/myblog Destination: E:/myblog/_site Incremental build: disabled. Enable with --incremental Generating... Generating Feed for posts done in 1.184 seconds. Auto regeneration: disabled. Use --watch to enable.
  • When you compile it, you see one_siteThis is the content of our static blog.

4. Run the preview

It’s also OK if we run a preview instead of compiling locally, and it will compile automatically.

E:\myblog>jekyll s Configuration file: E:/myblog/_config.yml Source: E:/myblog Destination: E:/myblog/_site Incremental build: disabled. Enable with --incremental Generating... Generating Feed for posts done in 0.847 seconds. Auto regeneration: Generating Feed for posts done in 0.847 seconds. Enabled for 'E:/myblog' Server address: http://127.0.0.1:4000/ Server running... press ctrl-c to stop.
  • You can specify port and IP here, and you can also control background running, as you can see10. Mnemonic instructions

5. Operation effect

  • How to use Jekyll to write a blog, can refer to the official website documentation

Blog structure

├ ─ ─ _config. Yml ├ ─ ─ _includes | ├ ─ ─ footer. The HTML | └ ─ ─ the header. The HTML ├ ─ ─ exactly | ├ ─ ─ the default. The HTML | ├ ─ ─ post. The HTML | └ ─ ─ Page. HTML ├ ─ ─ _posts | └ ─ ─ 2020-03-28 - welcome - to - jekyll. Markdown ├ ─ ─ _sass | ├ ─ ─ _base. SCSS | ├ ─ ─ _layout. SCSS | └ ─ ─ _syntax - highlighting. SCSS ├ ─ ─ the about the md ├ ─ ─ CSS | └ ─ ─. Main SCSS ├ ─ ─ feed. The XML └ ─ ─ index. The HTML

7. Cloning a blog (using templates)

Good! This is where our focus comes in. The default template is not ugly, but it’s not our blog. My goal here is to compile and run my personal blog locally. If you have a favorite template on your website or on someone else’s GitHub, you can download it to your local site.

1. Download the bundler

E:\itstack\gitee.com\fuzhengwei.github.io>gem install bundler Fetching: Bundler - 2.1.4.Gem (100%) Bundler's executable "bundle" Conflicts with D:/Ruby25-x64/bin/bundle Overwrite the executable?  [yN] n ERROR: Error installing bundler: "bundle" from bundler conflicts with D:/Ruby25-x64/bin/bundle

2. Installation environment

E:\itstack\gitee.com\fuzhengwei.github.io>bundle install Fetching gem metadata from http://gems.ruby-china.com/.......... Using rake 12.3.0 Fetching concurrency-Ruby 1.0.5 Installing concurrency-Ruby 1.0.5 Installing i18N Using Thread_Safe 0.3.6 Fetching Tzinfo 1.2.4 Installing Tzinfo 1.2.4 Fetching ActivePort 4.2.10... Lockfile (Nokogiri (~> 1.6)). Either installing with '--full-index' or running 'bundle update

3. Update Bundle (on demand)

E:\itstack\gitee.com\fuzhengwei.github.io>bundle update Fetching gem metadata from http://gems.ruby-china.com/........... Fetching gem metadata from http://gems.ruby-china.com/. Resolving dependencies.... Fetching Rake 13.0.1 (WAS 12.3.0)...

4. Compile

bundle exec jekyll build 

5. Run

bundle exec jekyll s

http://localhost: 4000 /

  • You can see that we have been running smoothly and visited the blog, the results are good.
  • This will run locally, so all the links will behttp://localhost:4000/, cannot be used for server-side deployment.

8. Manual release

If we are deploying to the server, then we must compile the links inside the address will start with our domain name, for example; https://bugstack.cn/. Next we start the compilation and use of the server-side deployment.

1. Clear and rebuild

Copyright (c) 2009 Microsoft Corporation. All rights reserved. All rights reserved. C:\Users\fuzhengwei>E: E:\>cd E:\itstack\gitee.com\fuzhengwei.github.io E:\itstack\gitee.com\fuzhengwei.github.io>bundle exec jekyll clean Configuration file: E:/itstack/gitee.com/fuzhengwei.github.io/_config.yml Cleaner: Removing ./_site... Cleaner: Nothing to do for ./.jekyll-metadata. Cleaner: Removing ./.jekyll-cache... Cleaner: Nothing to do for .sass-cache. E:\itstack\gitee.com\fuzhengwei.github.io>bundle exec jekyll build Configuration file: E:/itstack/gitee.com/fuzhengwei.github.io/_config.yml Source: E:/itstack/gitee.com/fuzhengwei.github.io Destination: E:/itstack/gitee.com/fuzhengwei.github.io/_site Incremental build: disabled. Enable with --incremental Generating... GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data. Done in 18.102 seconds. Auto-regeneration: disabled. Use --watch to enable. E:\itstack\gitee.com\fuzhengwei.github.io>
  • In the above we performed a clean (bundle exec jekyll clean) and build (bundle exec jekyll build), and then look under the file_siteContent generation.

2. Deploy to a remote server

Deployment of remote server mainly depends on the type of server used by children. I have a cloud virtual machine in my hand, and I can deploy it through FTP. The following;

  • After deployment, our online website can be accessed; https://bugstack.cn/

IX. Automatic distribution

If you compile the code locally every time you deploy it to the server, it will be a hassle to maintain the code on GitHub. Can be used; Github -> Travis ci-> Docker-> VPS But you still have to spend a little money to buy a server.

  • Submit the Markdown file locally to the GitHub source repository
  • GitHub triggers Travis CI to perform automatic compilation
  • After compiling Travis CI, push the static file to GitHub static file Repository
  • Travis CI notifies Docker to rebuild the image (estimated 5 minutes)
  • After the server sleeps for 5 minutes, Travis CI notifies the server
  • The server pulls the latest image, then stops and deletes the original container, and rebuilds the container with the latest image

At present, I do not have the money or time to do this, and I will invest in it when my blog has more page views and content.

10. Mnemonic instructions

The serial number instruction instructions
1 ruby -v View the Ruby version
2 gem update update
3 gem -v View the Gem version
4 gem install jekyll Install jekyll
5 gem install bundler Download the bundler
6 gem install jekyll-paginate Download jeky – paginate
7 git clone [email protected]:xiaofuge/xiaofuge.github.io.git Clone Themes (CD to Xiaofuge.github. IO, Execute Jekyll Serve is available inhttp://localhost:4000 see the effect)
8 gem sources –add https://gems.ruby-china.com/ –remove https://rubygems.org/ Change the sourcehttps://gems.ruby-china.com
9 jekyll new myblog Initialize the default blog
10 bundle install Go to the blog folder and perform initialization
11 jekyll build Local compilation defaults all links tohttp://localhost
13 jekyll build –source <source> –destination <destination> Compile the specified folder, and can be set to the specified place
12 jekyll build –destination Compile to the specified location
14 jekyll build –watch After compiling good automatic monitoring file changes automatically compiled
15 bundle exec jekyll build You just have to build your site (rather than provide it locally), and then you can upload the generated file to your server (this will generate a canonical link to the value of the configuration variable URL in _config.yml)
16 jekyll clean Clear the compile _site
17 jekyll serve Local Start-Up Service
18 Jekyll serve –host 0.0.0.0 –port 80 Specify IP and port to start
19 nohup jekyll serve & The background
20 ps -axu grep jekyll Run off
21 kill -9 [pid] Kill the process

XI. Summary

  • Through thisGitHubHanged, also thoroughly let my blog have to spend money to maintain. Not spending some money is really not a good idea! I endured it before; Speed, collection, experience, but all of a sudden, everything is gone. So can only hang on their own server, but the price is not expensive! After all, it is a virtual machine that can only support PHP and ASP.
  • There’s never been a thing that was easy, inNatural and man-madeWhen it comes, all that can help you resist is your accumulated ability. Like;It’s time to show real technology!
  • JekyllBuilding a blog is still pretty good, but also pretty easy to maintain. Technicians still need to have their own blog, through the constant toss from the inside of the continuous access to various technical points of breakthrough.

Recommended reading

  • So toss study graduate into big factory is not a problem
  • After two years of work, writing a poor resume will help you optimize
  • Tell me about my own learning route to give you some reference
  • Middleware development based on SpringBoot, to understand
  • "Based on Redis seckill, provide activity and inventory information query scenarios"