Build your own blogging system in Ubuntu

1. Prepare the environment

  • Operating system Ubuntu 16.04.1 LTS 64-bit

  • Install git

    sudo apt install git-core -y
    Copy the code
  • Install node using NVM

    #Install the NVM
    wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
    #Update the configuration to make the NVM command take effect
    source ~/.profile
    #Install the specified version of NodeNVM install <version> ---- Here I download Node 9.11.1 NVM install v9.11.1#Using v9.11.1NVM use v9.11.1#V9.11.1 is used by default (this command is valid if multiple versions of Node exist on the host)NVM alias default v9.11.1Copy the code
  • Installation Package Management Tool (NPM)

    #In order to improve the download speed, here to download the address specified Taobao mirror
    npm install -g cnpm --registry=https://registry.npm.taobao.org
    Copy the code
  • Install Hexo

    #Creating a folder
    mkdir hexo 
    #Enter folder
    cd hexo
    #This must be a global installation, otherwise the subsequent hexo command will not work
    cnpm install hexo-cli -g
    #Initialize hexo
    hexo init
    #Open the Hexo service
    hexo server 
    Copy the code

Open your browser, type http://127.0.0.1:4000, and you should see a simple blogging system

At this point, if you have your own server and domain name, you can directly deploy (there are many tutorials on Node deployment website, I will not go into the details), if you do not have a server can continue to look at the future.

Deploy your blog to Github

  • Registered making

  • Modifying Git Configuration

    #It must be consistent with your Github username and email addressGit config --global user.email git config --global user.emailCopy the code
  • Generating an SSH Key

    #SSH, just press enter all the way throughSsh-keygen -t rsa -b 4096 -c "Github registered email"#Starting the SSH Proxy
    eval $(ssh-agent -s)
    #Add the private key to the SSH proxy
    ssh-add ~/.ssh/id_rsa
    #View the public key of SSH and copy the printed content
    cat ~/.ssh/id_rsa.pub
    Copy the code

  • Add SSH to your GitHub account and paste in what you just copied

  • Create a Github repository. The repository name is in the format of userName. Github

  • Modify hexo’s configuration file

    #Go to hexo's directory
    cd hexo 
    #Modify the configuration file using vim
    vi _config.yml
    #Press the "I" key on the keyboard and -- INSERT -- appears in the lower left corner to enter the editing mode
    i
    #Locate deploy at the bottom of the file and replace it with the following content
    Copy the code
    deploy:
        type: git
        Replace the parentheses with your own username and repository name. Remove the parentheses
        repo: [email protected]:(BoView)/(BoView).github.io.git
        branch: master
    Copy the code

    The modified content is

    deploy:
        type: git
        repo: [email protected]:51TinTin/51TinTin.github.io.git
        branch: master
    Copy the code

    #After editing, press ESC to enter command mode
    ESC
    #Enter :wq to save the configuration and exit
    :wq
    
    Copy the code

Test and deploy

  • Execute the following commands in sequence
    #Clearing static pages
    hexo clean
    #Generating static pages
    hexo g
    #Deploy the public file content to the Github repository
    npm install hexo-deployer-git --save
    #The deployment of
    hexo d
    Copy the code

4. Bind domain names

After the operation to create my above warehouse as an example, my domain name is happynode.cn

  • To add a CNAME record in domain name resolution, we need to fill in the following content

    • The first column is the host record, so you can fill in whatever you want. I’ll write blog here
    • The second column record type, here we select CNAME
    • The fourth column record values: fill in 51 tintin / 51 tintin here. Dead simple. IO
    • The sixth column TTL, default 600 good

The domain name resolution process can sometimes take a long time, wait 5~10 minutes should be able to access

Done!!

If you want to create your own personalized blog, go to hexo’s official website and check out the portal