linux install hexo compilation blog


title: linux installed hexo compilation blog
categories: operation and maintenance
DATE: 2019-10-29 01:41:10
Tags: Linux
toc: to true
---

background

A few days ago to see the server to expire, did not go to him, to forget the results, expired early this morning, this Ali cloud 2 East China (Shanghai) also used the machines for nearly two years, the physical location in Shanghai let me uncomfortable obsessive-compulsive disorder, 40G and 30G of the plate are used (anyway, is go to the trouble of giving themselves an excuse), see the new machine has a student can be purchased at East 1 (Hangzhou) decisively release the original server, new purchased in Hangzhou node
before a pagoda made a backup strategy, so the data are stored in my OSS inside


a few days ago with hexo posted blog on github, but only on my own computer compilation, there are some limitations, so install hexo used to compile the blog in the clouds on this server.


Incidentally, found a BUG, Ali cloud student computers within the certification period, seems to be an unlimited number of renewals, the point I am going to keep the cost of living continued to try him eight or ten years.
Ado
----

installation

connect to the server

You tube cmd, xshell, hyper, putty or something, even on the get away

Installation node.js

This is a JavaScript runtime environment

  • From the official website to download the linux version of node.js or directly using wget to download

Use wget to download here

wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz

  • He unzipped

tar xf node-v10.9.0-linux-x64.tar.xz

  • After extracting test whether the installation is successful

Move to the directory

cd node-v10.9.0-linux-x64/
Excuting an order

./bin/node -v // 如果出现版本号,说明安装成功
Modify node-v10.9.0-linux-x64 folder name for nodejs

cd ..
mv node-v10.9.0-linux-x64 nodejs
  • Set the connection

    ln -s /soft/hexo/nodejs/bin/node /usr/local/bin/node
    ln -s /soft/hexo/nodejs/bin/npm /usr/local/bin/npm

git installation

  • Installation dependencies

    yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
    yum install gcc perl-ExtUtils-MakeMaker

Command git --versioncan see, Git current version number is 1.8.3.1, too old, we need to put it removed.

  • Uninstall the old version of Git
    yum remove git
  • Download and unzip

    https://github.com/git/git/archive/v2.9.2.tar.gz wget
    tar -zxvf v2.9.2.tar.gz // extract the
    mv v2.9.2.tar.gz git // rename

  • Compile and install

    cd git // into the folder
    make prefix = / usr / local / git all // compile source
    mounted to the / usr / local / git path make prefix = / usr / local / git install //

Compile time configuration determines the speed of the machine, please be patient.

  • Open environment variable configuration file
    vim /etc/profile

In the bottom of the configuration file to add the following.

PATH=$PATH:/usr/local/git/bin // git 的目录
export PATH

Two statements should be added

Refresh environment variable
source /etc/profile
and finally use git --versionto view the version number, 2.9.2 already

Installation hexo

npm install hexo-cli -g

Build a blog basis

  • Add hexo first command to the global: hexo lib in the nodejs / node_modules / hexo-cli / bin command can be found hexo way is to use flexible connections

    ln -s /soft/hexo/nodejs/lib/node_modules/hexo-cli/bin/hexo /usr/local/bin/hexo`

  • Hexo blog deployment environment: this can be placed outside nodejs, easy to open
    next cd to a directory and nodejs (I was on the root directory) and then:

    HEXO mkdir
    cd HEXO
    HEXO the init // will automatically download a good resource file

Explain
node_modules: dependencies is
public: is stored in the page generated
scaffolds: command to generate articles and other templates
source: Create a command of various articles
themes: Theme
_config.yml: entire blog configuration
db.json: source parsing the the resulting
package.json: the configuration information required for the project module project

  • Bypass to github

Create a repo, the name of yourname.github.iowhich is yourname github name (I already have, not a screenshot)

Configuration github account information

git config --global user.name "yourname"
git config --global user.email "youremail"

Creating SSH

In gitbash input: ssh-keygen -t rsa -C "[email protected]generating ssh

SSH and GPG keys found on github the setting, click the New SSH key

title taken lightly, key to fill that period just ssh

Verify added successfully in gitbash in:ssh -T [email protected]

  • a step far

Open your blog with the project editor, _config.yml modify some configuration files (all have a half-width space after the colon)

deploy:
type: git
repo: https://github.com/YourgithubName/YourgithubName.github.io.git
branch: master

Gitbash back in, into your blog directory, respectively, execute the following command

hexo clean
hexo generate
hexo server
  • Start the test environment

hexo s

Entry localhost:4000/

If a server, I was Ali cloud server, you need to configure security group to open the 4000 port, so you can access locally
or linux virtual machine, you need to test whether the normal internal and external communication

Enter ip: 4000 / to access the initial page hexo


Thus, the basic hexo to build a good environment.

Guess you like

Origin www.cnblogs.com/lajix/p/11756553.html