IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Hexo:Install on CentOS 7

    Adamhuan发表于 2017-01-13 17:42:44
    love 0

    Hexo,是一个Markdown的轻量级博客框架。

    官方网站:https://hexo.io

    它的安装非常简单,官方网提供了详细的文档:
    https://hexo.io/zh-cn/docs/

    本文为在我自己的环境中的实验过程。

    1. 安装GIT支持:

    [root@center-linux software]# yum install -y git
    Loaded plugins: fastestmirror, langpacks
    base                                                                                          | 3.6 kB  00:00:00     
    extras                                                                                        | 3.4 kB  00:00:00     
    gitlab-ce                                                                                     | 2.9 kB  00:00:00     
    gitlab_gitlab-ee-source/signature                                                             |  836 B  00:00:00     
    gitlab_gitlab-ee-source/signature                                                             |  951 B  00:00:00 
    updates                                                                                       | 3.4 kB  00:00:00     
    (1/3): extras/7/x86_64/primary_db                                                             |  97 kB  00:00:04     
    (2/3): gitlab-ce/primary_db                                                                   | 1.2 MB  00:00:06     
    (3/3): updates/7/x86_64/primary_db                                                            | 1.3 MB  00:00:06     
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.163.com
     * updates: centos.ustc.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.x86_64 0:1.8.3.1-4.el7 will be updated
    --> Processing Dependency: git = 1.8.3.1-4.el7 for package: perl-Git-1.8.3.1-4.el7.noarch
    ---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be an update
    --> Running transaction check
    ---> Package perl-Git.noarch 0:1.8.3.1-4.el7 will be updated
    ---> Package perl-Git.noarch 0:1.8.3.1-6.el7_2.1 will be an update
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =====================================================================================================================
     Package                   Arch                    Version                               Repository             Size
    =====================================================================================================================
    Updating:
     git                       x86_64                  1.8.3.1-6.el7_2.1                     base                  4.4 M
    Updating for dependencies:
     perl-Git                  noarch                  1.8.3.1-6.el7_2.1                     base                   53 k
    
    Transaction Summary
    =====================================================================================================================
    Upgrade  1 Package (+1 Dependent package)
    
    Total size: 4.4 M
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Updating   : git-1.8.3.1-6.el7_2.1.x86_64                                                                      1/4 
      Updating   : perl-Git-1.8.3.1-6.el7_2.1.noarch                                                                 2/4 
      Cleanup    : git-1.8.3.1-4.el7.x86_64                                                                          3/4 
      Cleanup    : perl-Git-1.8.3.1-4.el7.noarch                                                                     4/4 
      Verifying  : perl-Git-1.8.3.1-6.el7_2.1.noarch                                                                 1/4 
      Verifying  : git-1.8.3.1-6.el7_2.1.x86_64                                                                      2/4 
      Verifying  : perl-Git-1.8.3.1-4.el7.noarch                                                                     3/4 
      Verifying  : git-1.8.3.1-4.el7.x86_64                                                                          4/4 
    
    Updated:
      git.x86_64 0:1.8.3.1-6.el7_2.1                                                                                     
    
    Dependency Updated:
      perl-Git.noarch 0:1.8.3.1-6.el7_2.1                                                                                
    
    Complete!
    [root@center-linux software]# 
    [root@center-linux software]# rpm -qa | grep ^git
    git-1.8.3.1-6.el7_2.1.x86_64
    gitlab-ce-8.15.3-ce.0.el7.x86_64
    [root@center-linux software]# 
    [root@center-linux software]# git --version
    git version 1.8.3.1
    [root@center-linux software]#

    可以看到,当前的GIT版本为:1.8.3.1

    除了上面的方法YUM安装,也可以去GIT的官方网站获取安装介质。
    GIT的官方网站:
    https://www.git-scm.com/

    当前最新版本的GIT为:2.11.0

    2. 安装Node.js支持:
    Node.js的官方网站为:
    http://nodejs.org/
    最新版本为:7.4.0

    1) 从官方网站获取的介质安装
    从官方网站获取安装介质:

    [root@center-linux software]# pwd
    /software
    [root@center-linux software]# mkdir nodejs
    [root@center-linux software]# cd nodejs/
    [root@center-linux nodejs]# ls -ltr
    total 0
    [root@center-linux nodejs]# 
    [root@center-linux nodejs]# wget https://nodejs.org/dist/v7.4.0/node-v7.4.0-linux-x64.tar.xz
    --2017-01-13 22:22:41--  https://nodejs.org/dist/v7.4.0/node-v7.4.0-linux-x64.tar.xz
    Resolving nodejs.org (nodejs.org)... 104.20.22.46, 104.20.23.46, 2400:cb00:2048:1::6814:172e, ...
    Connecting to nodejs.org (nodejs.org)|104.20.22.46|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 10318700 (9.8M) [application/x-xz]
    Saving to: ‘node-v7.4.0-linux-x64.tar.xz’
    
    100%[===========================================================================>] 10,318,700  30.5KB/s   in 4m 52s 
    
    2017-01-13 22:27:34 (34.5 KB/s) - ‘node-v7.4.0-linux-x64.tar.xz’ saved [10318700/10318700]
    
    [root@center-linux nodejs]# 
    [root@center-linux nodejs]# ls -ltr
    total 19212
    -rw-r--r--. 1 root root 10318700 Jan  5 01:19 node-v7.4.0-linux-x64.tar.xz
    -rw-r--r--. 1 root root  9348020 Jan  6 04:51 node-v6.9.4-linux-x64.tar.xz
    [root@center-linux nodejs]# 
    [root@center-linux nodejs]# du -sh *
    9.0M    node-v6.9.4-linux-x64.tar.xz
    9.9M    node-v7.4.0-linux-x64.tar.xz
    [root@center-linux nodejs]#

    解压缩安装介质:

    [root@center-linux nodejs]# xz -d node-v7.4.0-linux-x64.tar.xz 
    [root@center-linux nodejs]# ls -ltr
    total 60064
    -rw-r--r--. 1 root root 52152320 Jan  5 01:19 node-v7.4.0-linux-x64.tar
    -rw-r--r--. 1 root root  9348020 Jan  6 04:51 node-v6.9.4-linux-x64.tar.xz
    [root@center-linux nodejs]# 
    [root@center-linux nodejs]# tar -xf node-v7.4.0-linux-x64.tar 
    [root@center-linux nodejs]# ls -ltr
    total 60064
    drwxrwxr-x. 6  500  500      101 Jan  5 01:18 node-v7.4.0-linux-x64
    -rw-r--r--. 1 root root 52152320 Jan  5 01:19 node-v7.4.0-linux-x64.tar
    -rw-r--r--. 1 root root  9348020 Jan  6 04:51 node-v6.9.4-linux-x64.tar.xz
    [root@center-linux nodejs]# 
    [root@center-linux nodejs]# cd node-v7.4.0-linux-x64/
    [root@center-linux node-v7.4.0-linux-x64]# ls -ltr
    total 136
    drwxrwxr-x. 5 500 500    42 Jan  5 01:18 share
    drwxrwxr-x. 3 500 500    25 Jan  5 01:18 lib
    -rw-rw-r--. 1 500 500 17535 Jan  5 01:18 README.md
    -rw-rw-r--. 1 500 500 60255 Jan  5 01:18 LICENSE
    drwxrwxr-x. 3 500 500    17 Jan  5 01:18 include
    -rw-rw-r--. 1 500 500 55985 Jan  5 01:18 CHANGELOG.md
    drwxrwxr-x. 2 500 500    27 Jan  5 01:18 bin
    [root@center-linux node-v7.4.0-linux-x64]#

    将解压后的文件,移动到服务器的NodeJS的目录【/usr/local/nodejs】之中:

    [root@center-linux node-v7.4.0-linux-x64]# ls -ltr /usr/local/
    total 0
    drwxr-xr-x. 2 root root  6 Jun 10  2014 src
    drwxr-xr-x. 2 root root  6 Jun 10  2014 sbin
    drwxr-xr-x. 2 root root  6 Jun 10  2014 libexec
    drwxr-xr-x. 2 root root  6 Jun 10  2014 lib64
    drwxr-xr-x. 2 root root  6 Jun 10  2014 lib
    drwxr-xr-x. 2 root root  6 Jun 10  2014 include
    drwxr-xr-x. 2 root root  6 Jun 10  2014 games
    drwxr-xr-x. 2 root root  6 Jun 10  2014 etc
    drwxr-xr-x. 5 root root 46 Jan 11 09:41 share
    drwxr-xr-x. 3 root root 17 Jan 12 14:30 man
    drwxr-xr-x. 2 root root 16 Jan 12 14:40 bin
    [root@center-linux node-v7.4.0-linux-x64]# 
    [root@center-linux node-v7.4.0-linux-x64]# mkdir /usr/local/nodejs
    [root@center-linux node-v7.4.0-linux-x64]# pwd
    /software/nodejs/node-v7.4.0-linux-x64
    [root@center-linux node-v7.4.0-linux-x64]# ls -ltr
    total 136
    drwxrwxr-x. 5 500 500    42 Jan  5 01:18 share
    drwxrwxr-x. 3 500 500    25 Jan  5 01:18 lib
    -rw-rw-r--. 1 500 500 17535 Jan  5 01:18 README.md
    -rw-rw-r--. 1 500 500 60255 Jan  5 01:18 LICENSE
    drwxrwxr-x. 3 500 500    17 Jan  5 01:18 include
    -rw-rw-r--. 1 500 500 55985 Jan  5 01:18 CHANGELOG.md
    drwxrwxr-x. 2 500 500    27 Jan  5 01:18 bin
    [root@center-linux node-v7.4.0-linux-x64]# 
    [root@center-linux node-v7.4.0-linux-x64]# mv * /usr/local/nodejs/
    [root@center-linux node-v7.4.0-linux-x64]# ls
    [root@center-linux node-v7.4.0-linux-x64]# ls -ltr /usr/local/nodejs/
    total 136
    drwxrwxr-x. 5 500 500    42 Jan  5 01:18 share
    drwxrwxr-x. 3 500 500    25 Jan  5 01:18 lib
    -rw-rw-r--. 1 500 500 17535 Jan  5 01:18 README.md
    -rw-rw-r--. 1 500 500 60255 Jan  5 01:18 LICENSE
    drwxrwxr-x. 3 500 500    17 Jan  5 01:18 include
    -rw-rw-r--. 1 500 500 55985 Jan  5 01:18 CHANGELOG.md
    drwxrwxr-x. 2 500 500    27 Jan  5 01:18 bin
    [root@center-linux node-v7.4.0-linux-x64]#

    配置环境变量:

    [root@center-linux ~]# cat ~/.bash_profile | grep --color nodejs
    PATH=$PATH:/usr/local/nodejs/bin:/usr/bin/sh:/usr/bin/make:$HOME/bin
    [root@center-linux ~]# 
    [root@center-linux ~]# source ~/.bash_profile 
    [root@center-linux ~]# 
    [root@center-linux ~]# env | grep --color nodejs
    OLDPWD=/software/nodejs/node-v7.4.0-linux-x64
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/bin/sh:/usr/bin/make:/root/bin:/usr/local/nodejs/bin:/usr/bin/sh:/usr/bin/make:/root/bin
    [root@center-linux ~]# 
    [root@center-linux ~]# node --version
    v7.4.0
    [root@center-linux ~]# npm --version
    4.0.5
    [root@center-linux ~]#

    这样,Node.js就安装好了。

    2) 通过NVM的方式安装

    NVM官方网站:
    http://nvm.sh
    https://github.com/creationix/nvm/blob/master/README.markdown

    安装NVM:
    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

    [root@center-linux ~]# cd /software
    [root@center-linux software]# mkdir nvm
    [root@center-linux software]# cd nvm/
    [root@center-linux nvm]# 
    [root@center-linux nvm]# wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh > nvm_install.sh
    [root@center-linux nvm]# 
    [root@center-linux nvm]# ls -ltr
    total 12
    -rw-r--r--. 1 root root 11329 Jan 13 22:57 nvm_install.sh
    [root@center-linux nvm]# 
    [root@center-linux nvm]# cat nvm_install.sh 
    #!/usr/bin/env bash
    
    { # this ensures the entire script is downloaded #
    
    nvm_has() {
      type "$1" > /dev/null 2>&1
    }
    
    nvm_install_dir() {
      echo "${NVM_DIR:-"$HOME/.nvm"}"
    }
    
    nvm_latest_version() {
      echo "v0.33.0"
    }
    
    #
    # Outputs the location to NVM depending on:
    # * The availability of $NVM_SOURCE
    # * The method used ("script" or "git" in the script, defaults to "git")
    # NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
    #
    nvm_source() {
      local NVM_METHOD
      NVM_METHOD="$1"
      local NVM_SOURCE_URL
      NVM_SOURCE_URL="$NVM_SOURCE"
      if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
        NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
      elif [ -z "$NVM_SOURCE_URL" ]; then
        if [ "_$NVM_METHOD" = "_script" ]; then
          NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
        elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
          NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
        else
          echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
          return 1
        fi
      fi
      echo "$NVM_SOURCE_URL"
    }
    
    #
    # Node.js version to install
    #
    nvm_node_version() {
      echo "$NODE_VERSION"
    }
    
    nvm_download() {
      if nvm_has "curl"; then
        curl -q "$@"
      elif nvm_has "wget"; then
        # Emulate curl with wget
        ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
                               -e 's/-L //' \
                               -e 's/-I /--server-response /' \
                               -e 's/-s /-q /' \
                               -e 's/-o /-O /' \
                               -e 's/-C - /-c /')
        # shellcheck disable=SC2086
        eval wget $ARGS
      fi
    }
    
    install_nvm_from_git() {
      local INSTALL_DIR
      INSTALL_DIR="$(nvm_install_dir)"
    
      if [ -d "$INSTALL_DIR/.git" ]; then
        echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
        command printf "\r=> "
        command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || {
          echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
          exit 1
        }
      else
        # Cloning to $INSTALL_DIR
        echo "=> Downloading nvm from git to '$INSTALL_DIR'"
        command printf "\r=> "
        mkdir -p "${INSTALL_DIR}"
        if [ "$(ls -A "${INSTALL_DIR}")" ]; then
          command git init "${INSTALL_DIR}" || {
            echo >&2 'Failed to initialize nvm repo. Please report this!'
            exit 2
          }
          command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
            || command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
            echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
            exit 2
          }
          command git --git-dir="${INSTALL_DIR}/.git" fetch origin --tags || {
            echo >&2 'Failed to fetch origin with tags. Please report this!'
            exit 2
          }
        else
          command git clone "$(nvm_source)" "${INSTALL_DIR}" || {
            echo >&2 'Failed to clone nvm repo. Please report this!'
            exit 2
          }
        fi
      fi
      command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)"
      if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
        if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
          command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
        else
          echo >&2 "Your version of git is out of date. Please update it!"
          command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1
        fi
      fi
    
      echo "=> Compressing and cleaning up git repository"
      if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --aggressive --prune=now ; then
          echo >&2 "Your version of git is out of date. Please update it!"
      fi
      return
    }
    
    #
    # Automatically install Node.js
    #
    nvm_install_node() {
      local NODE_VERSION
      NODE_VERSION="$(nvm_node_version)"
    
      if [ -z "$NODE_VERSION" ]; then
        return 0
      fi
    
      echo "=> Installing Node.js version $NODE_VERSION"
      nvm install "$NODE_VERSION"
      local CURRENT_NVM_NODE
    
      CURRENT_NVM_NODE="$(nvm_version current)"
      if [ "$(nvm_version "$NODE_VERSION")" == "$CURRENT_NVM_NODE" ]; then
        echo "=> Node.js version $NODE_VERSION has been successfully installed"
      else
        echo >&2 "Failed to install Node.js $NODE_VERSION"
      fi
    }
    
    install_nvm_as_script() {
      local INSTALL_DIR
      INSTALL_DIR="$(nvm_install_dir)"
      local NVM_SOURCE_LOCAL
      NVM_SOURCE_LOCAL=$(nvm_source script)
      local NVM_EXEC_SOURCE
      NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
    
      # Downloading to $INSTALL_DIR
      mkdir -p "$INSTALL_DIR"
      if [ -f "$INSTALL_DIR/nvm.sh" ]; then
        echo "=> nvm is already installed in $INSTALL_DIR, trying to update the script"
      else
        echo "=> Downloading nvm as script to '$INSTALL_DIR'"
      fi
      nvm_download -s "$NVM_SOURCE_LOCAL" -o "$INSTALL_DIR/nvm.sh" || {
        echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
        return 1
      }
      nvm_download -s "$NVM_EXEC_SOURCE" -o "$INSTALL_DIR/nvm-exec" || {
        echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
        return 2
      }
      chmod a+x "$INSTALL_DIR/nvm-exec" || {
        echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"
        return 3
      }
    }
    
    #
    # Detect profile file if not specified as environment variable
    # (eg: PROFILE=~/.myprofile)
    # The echo'ed path is guaranteed to be an existing file
    # Otherwise, an empty string is returned
    #
    nvm_detect_profile() {
      if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
        echo "${PROFILE}"
        return
      fi
    
      local DETECTED_PROFILE
      DETECTED_PROFILE=''
      local SHELLTYPE
      SHELLTYPE="$(basename "/$SHELL")"
    
      if [ "$SHELLTYPE" = "bash" ]; then
        if [ -f "$HOME/.bashrc" ]; then
          DETECTED_PROFILE="$HOME/.bashrc"
        elif [ -f "$HOME/.bash_profile" ]; then
          DETECTED_PROFILE="$HOME/.bash_profile"
        fi
      elif [ "$SHELLTYPE" = "zsh" ]; then
        DETECTED_PROFILE="$HOME/.zshrc"
      fi
    
      if [ -z "$DETECTED_PROFILE" ]; then
        if [ -f "$HOME/.profile" ]; then
          DETECTED_PROFILE="$HOME/.profile"
        elif [ -f "$HOME/.bashrc" ]; then
          DETECTED_PROFILE="$HOME/.bashrc"
        elif [ -f "$HOME/.bash_profile" ]; then
          DETECTED_PROFILE="$HOME/.bash_profile"
        elif [ -f "$HOME/.zshrc" ]; then
          DETECTED_PROFILE="$HOME/.zshrc"
        fi
      fi
    
      if [ ! -z "$DETECTED_PROFILE" ]; then
        echo "$DETECTED_PROFILE"
      fi
    }
    
    #
    # Check whether the user has any globally-installed npm modules in their system
    # Node, and warn them if so.
    #
    nvm_check_global_modules() {
      command -v npm >/dev/null 2>&1 || return 0
    
      local NPM_VERSION
      NPM_VERSION="$(npm --version)"
      NPM_VERSION="${NPM_VERSION:--1}"
      [ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0
    
      local NPM_GLOBAL_MODULES
      NPM_GLOBAL_MODULES="$(
        npm list -g --depth=0 |
        command sed '/ npm@/d' |
        command sed '/ (empty)$/d'
      )"
    
      local MODULE_COUNT
      MODULE_COUNT="$(
        command printf %s\\n "$NPM_GLOBAL_MODULES" |
        command sed -ne '1!p' |                     # Remove the first line
        wc -l | tr -d ' '                           # Count entries
      )"
    
      if [ "${MODULE_COUNT}" != '0' ]; then
        # shellcheck disable=SC2016
        echo '=> You currently have modules installed globally with `npm`. These will no'
        # shellcheck disable=SC2016
        echo '=> longer be linked to the active version of Node when you install a new node'
        # shellcheck disable=SC2016
        echo '=> with `nvm`; and they may (depending on how you construct your `$PATH`)'
        # shellcheck disable=SC2016
        echo '=> override the binaries of modules installed with `nvm`:'
        echo
    
        command printf %s\\n "$NPM_GLOBAL_MODULES"
        echo '=> If you wish to uninstall them at a later point (or re-install them under your'
        # shellcheck disable=SC2016
        echo '=> `nvm` Nodes), you can remove them from the system Node as follows:'
        echo
        echo '     $ nvm use system'
        echo '     $ npm uninstall -g a_module'
        echo
      fi
    }
    
    nvm_do_install() {
      if [ -z "${METHOD}" ]; then
        # Autodetect install method
        if nvm_has git; then
          install_nvm_from_git
        elif nvm_has nvm_download; then
          install_nvm_as_script
        else
          echo >&2 'You need git, curl, or wget to install nvm'
          exit 1
        fi
      elif [ "${METHOD}" = 'git' ]; then
        if ! nvm_has git; then
          echo >&2 "You need git to install nvm"
          exit 1
        fi
        install_nvm_from_git
      elif [ "${METHOD}" = 'script' ]; then
        if ! nvm_has nvm_download; then
          echo >&2 "You need curl or wget to install nvm"
          exit 1
        fi
        install_nvm_as_script
      fi
    
      echo
    
      local NVM_PROFILE
      NVM_PROFILE="$(nvm_detect_profile)"
      local INSTALL_DIR
      INSTALL_DIR="$(nvm_install_dir)"
    
      SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\"  # This loads nvm\n"
      COMPLETION_STR="[ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\"  # This loads nvm bash_completion\n"
      BASH_OR_ZSH=false
    
      if [ -z "${NVM_PROFILE-}" ] ; then
        echo "=> Profile not found. Tried ${NVM_PROFILE} (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
        echo "=> Create one of them and run this script again"
        echo "=> Create it (touch ${NVM_PROFILE}) and run this script again"
        echo "   OR"
        echo "=> Append the following lines to the correct file yourself:"
        command printf "${SOURCE_STR}"
      else
        case "${NVM_PROFILE-}" in
          ".bashrc" | ".bash_profile" | ".zshrc")
            BASH_OR_ZSH=true
          ;;
        esac
        if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
          echo "=> Appending nvm source string to $NVM_PROFILE"
          command printf "${SOURCE_STR}" >> "$NVM_PROFILE"
        else
          echo "=> nvm source string already in ${NVM_PROFILE}"
        fi
        # shellcheck disable=SC2016
        if ${BASH_OR_ZSH} && ! command grep -qc '$NVM_DIR/bash_completion' "$NVM_PROFILE"; then
          echo "=> Appending bash_completion source string to $NVM_PROFILE"
          command printf "$COMPLETION_STR" >> "$NVM_PROFILE"
        else
          echo "=> bash_completion source string already in ${NVM_PROFILE}"
        fi
      fi
      if ${BASH_OR_ZSH} && [ -z "${NVM_PROFILE-}" ] ; then
        echo "=> Please also append the following lines to the if you are using bash/zsh shell:"
        command printf "${COMPLETION_STR}"
      fi
    
      # Source nvm
      # shellcheck source=/dev/null
      \. "${INSTALL_DIR}/nvm.sh"
    
      nvm_check_global_modules
    
      nvm_install_node
    
      nvm_reset
    
      echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
      command printf "${SOURCE_STR}"
      if ${BASH_OR_ZSH} ; then
        command printf " && ${COMPLETION_STR}"
      fi
    }
    
    #
    # Unsets the various functions defined
    # during the execution of the install script
    #
    nvm_reset() {
      unset -f nvm_reset nvm_has nvm_latest_version \
        nvm_source nvm_download install_nvm_as_script install_nvm_from_git \
        nvm_detect_profile nvm_check_global_modules nvm_do_install \
        nvm_install_dir nvm_node_version nvm_install_node
    }
    
    [ "_$NVM_ENV" = "_testing" ] || nvm_do_install
    
    } # this ensures the entire script is downloaded #
    [root@center-linux nvm]# 
    [root@center-linux nvm]# 
    
    执行脚本:
    [root@center-linux nvm]# ls
    nvm_install.sh
    [root@center-linux nvm]# 
    [root@center-linux nvm]# sh nvm_install.sh 
    => Downloading nvm from git to '/root/.nvm'
    => Cloning into '/root/.nvm'...
    remote: Counting objects: 6072, done.
    remote: Compressing objects: 100% (6/6), done.
    remote: Total 6072 (delta 0), reused 0 (delta 0), pack-reused 6066
    Receiving objects: 100% (6072/6072), 1.72 MiB | 97.00 KiB/s, done.
    Resolving deltas: 100% (3774/3774), done.
    * (detached from v0.33.0)
      master
    => Compressing and cleaning up git repository
    Counting objects: 6072, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (6034/6034), done.
    Writing objects: 100% (6072/6072), done.
    Total 6072 (delta 4010), reused 1856 (delta 0)
    
    => Appending nvm source string to /root/.bashrc
    => bash_completion source string already in /root/.bashrc
    => Close and reopen your terminal to start using nvm or run the following to use it now:
    
    export NVM_DIR="/root/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [root@center-linux nvm]# 
    
    执行结果:
    [root@center-linux nvm]# ls -ltra ~/ | grep nvm
    drwxr-xr-x.  5 root root 4096 Jan 13 22:59 .nvm
    [root@center-linux nvm]# 
    [root@center-linux nvm]# ls -ltr ~/.nvm/
    total 172
    -rw-r--r--. 1 root root   908 Jan 13 22:59 ROADMAP.md
    -rw-r--r--. 1 root root  5196 Jan 13 22:59 Makefile
    -rw-r--r--. 1 root root  1084 Jan 13 22:59 LICENSE.md
    -rw-r--r--. 1 root root   763 Jan 13 22:59 CONTRIBUTING.md
    -rw-r--r--. 1 root root  1912 Jan 13 22:59 bash_completion
    -rw-r--r--. 1 root root  1749 Jan 13 22:59 package.json
    -rwxr-xr-x. 1 root root 98499 Jan 13 22:59 nvm.sh
    -rwxr-xr-x. 1 root root   344 Jan 13 22:59 nvm-exec
    drwxr-xr-x. 9 root root  4096 Jan 13 22:59 test
    -rwxr-xr-x. 1 root root  1398 Jan 13 22:59 update_test_mocks.sh
    -rw-r--r--. 1 root root 20238 Jan 13 22:59 README.markdown
    -rwxr-xr-x. 1 root root 11329 Jan 13 22:59 install.sh
    [root@center-linux nvm]#

    配置NVM的环境变量:

    [root@center-linux nvm]# cat ~/.bash_profile 
    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    
    PATH=$PATH:/usr/local/nodejs/bin:/usr/bin/sh:/usr/bin/make:$HOME/bin
    
    export PATH
    
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
    [root@center-linux nvm]# 
    [root@center-linux nvm]# source ~/.bash_profile 
    [root@center-linux nvm]#

    查看一下NVM的状态:

    [root@center-linux nvm]# nvm --help
    
    Node Version Manager
    
    Note:  refers to any version-like string nvm understands. This includes:
      - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
      - default (built-in) aliases: node, stable, unstable, iojs, system
      - custom aliases you define with `nvm alias foo`
    
     Any options that produce colorized output should respect the `--no-colors` option.
    
    Usage:
      nvm --help                                Show this message
      nvm --version                             Print out the latest released version of nvm
      nvm install [-s]                 Download and install a , [-s] from source. Uses .nvmrc if available
        --reinstall-packages-from=     When installing, reinstall packages installed in 
        --lts                                   When installing, only select from LTS (long-term support) versions
        --lts=                        When installing, only select from versions for a specific LTS line
      nvm uninstall                    Uninstall a version
      nvm uninstall --lts                       Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.
      nvm uninstall --lts=            Uninstall using automatic alias for provided LTS line, if available.
      nvm use [--silent]               Modify PATH to use . Uses .nvmrc if available
        --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.
        --lts=                        Uses automatic alias for provided LTS line, if available.
      nvm exec [--silent]  [] Run  on . Uses .nvmrc if available
        --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.
        --lts=                        Uses automatic alias for provided LTS line, if available.
      nvm run [--silent]  []     Run `node` on  with  as arguments. Uses .nvmrc if available
        --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.
        --lts=                        Uses automatic alias for provided LTS line, if available.
      nvm current                               Display currently activated version
      nvm ls                                    List installed versions
      nvm ls                           List versions matching a given 
      nvm ls-remote                             List remote versions available for install
        --lts                                   When listing, only show LTS (long-term support) versions
      nvm ls-remote                    List remote versions available for install, matching a given 
        --lts                                   When listing, only show LTS (long-term support) versions
        --lts=                        When listing, only show versions for a specific LTS line
      nvm version                      Resolve the given description to a single local version
      nvm version-remote               Resolve the given description to a single remote version
        --lts                                   When listing, only select from LTS (long-term support) versions
        --lts=                        When listing, only select from versions for a specific LTS line
      nvm deactivate                            Undo effects of `nvm` on current shell
      nvm alias []                     Show all aliases beginning with 
      nvm alias                  Set an alias named  pointing to 
      nvm unalias                         Deletes the alias named 
      nvm reinstall-packages           Reinstall global `npm` packages contained in  to current version
      nvm unload                                Unload `nvm` from shell
      nvm which []                     Display path to installed node version. Uses .nvmrc if available
      nvm cache dir                             Display path to the cache directory for nvm
      nvm cache clear                           Empty cache directory for nvm
    
    Example:
      nvm install v0.10.32                  Install a specific version number
      nvm use 0.10                          Use the latest available 0.10.x release
      nvm run 0.10.32 app.js                Run app.js using node v0.10.32
      nvm exec 0.10.32 node app.js          Run `node app.js` with the PATH pointing to node v0.10.32
      nvm alias default 0.10.32             Set default node version on a shell
    
    Note:
      to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usually `~/.nvm`)
    
    [root@center-linux nvm]# 
    [root@center-linux nvm]# nvm --version
    0.33.0
    [root@center-linux nvm]# 
    [root@center-linux nvm]#

    通过NVM安装Node.js:
    nvm install stable

    [root@center-linux nvm]# nvm install stable
    Downloading and installing node v7.4.0...
    Local cache found: $NVM_DIR/.cache/bin/node-v7.4.0-linux-x64/node-v7.4.0-linux-x64.tar.xz
    Computing checksum with sha256sum
    Checksums do not match: '70b5556a6f9a348d5fef3f6c6d1a5fe7a3e02cfeb3036f5ab092c3ff9e46de94' found, 'c847251538579d605ac391c5e282ad40b2ead0414df7699f58781d9e6e80248a' expected.
    Checksum check failed!
    Removing the broken local cache...
    Downloading https://nodejs.org/dist/v7.4.0/node-v7.4.0-linux-x64.tar.xz...
    ######################################################################## 100.0%
    Computing checksum with sha256sum
    Checksums matched!
    Now using node v7.4.0 (npm v4.0.5)
    [root@center-linux nvm]# 
    [root@center-linux nvm]# nvm install v6.9.0
    Downloading and installing node v6.9.0...
    Downloading https://nodejs.org/dist/v6.9.0/node-v6.9.0-linux-x64.tar.xz...
    ######################################################################## 100.0%
    Computing checksum with sha256sum
    Checksums matched!
    Now using node v6.9.0 (npm v3.10.8)
    Creating default alias: default -> v6.9.0 *
    [root@center-linux nvm]#

    像上面这样跟上版本号也是可行的安装方法。

    查看下安装了的软件版本:

    [root@center-linux nvm]# nvm ls
             v6.9.0 *
    ->       v7.4.0 *
             system
    default -> v6.9.0 *
    node -> stable (-> v7.4.0 *) (default)
    stable -> 7.4 (-> v7.4.0 *) (default)
    iojs -> N/A (default)
    lts/* -> lts/boron (-> N/A)
    lts/argon -> v4.7.2 (-> N/A)
    lts/boron -> v6.9.4 (-> N/A)
    [root@center-linux nvm]#

    3. 安装HEXO
    npm install -g hexo-cli

    [root@center-linux ~]# npm install -g hexo-cli
    /usr/local/nodejs/bin/hexo -> /usr/local/nodejs/lib/node_modules/hexo-cli/bin/hexo
    
    > dtrace-provider@0.8.0 install /usr/local/nodejs/lib/node_modules/hexo-cli/node_modules/dtrace-provider
    > node scripts/install.js
    
    
    > hexo-util@0.6.0 postinstall /usr/local/nodejs/lib/node_modules/hexo-cli/node_modules/hexo-util
    > npm run build:highlight
    
    
    > hexo-util@0.6.0 build:highlight /usr/local/nodejs/lib/node_modules/hexo-cli/node_modules/hexo-util
    > node scripts/build_highlight_alias.js > highlight_alias.json
    
    /usr/local/nodejs/lib
    └─┬ hexo-cli@1.0.2 
      ├── abbrev@1.0.9 
      ├── bluebird@3.4.7 
      ├─┬ chalk@1.1.3 
      │ ├── ansi-styles@2.2.1 
      │ ├── escape-string-regexp@1.0.5 
      │ ├─┬ has-ansi@2.0.0 
      │ │ └── ansi-regex@2.0.0 
      │ ├── strip-ansi@3.0.1 
      │ └── supports-color@2.0.0 
      ├─┬ hexo-fs@0.1.6 
      │ ├─┬ chokidar@1.6.1 
      │ │ ├─┬ anymatch@1.3.0 
      │ │ │ ├── arrify@1.0.1 
      │ │ │ └─┬ micromatch@2.3.11 
      │ │ │   ├─┬ arr-diff@2.0.0 
      │ │ │   │ └── arr-flatten@1.0.1 
      │ │ │   ├── array-unique@0.2.1 
      │ │ │   ├─┬ braces@1.8.5 
      │ │ │   │ ├─┬ expand-range@1.8.2 
      │ │ │   │ │ └─┬ fill-range@2.2.3 
      │ │ │   │ │   ├── is-number@2.1.0 
      │ │ │   │ │   ├── isobject@2.1.0 
      │ │ │   │ │   ├── randomatic@1.1.6 
      │ │ │   │ │   └── repeat-string@1.6.1 
      │ │ │   │ ├── preserve@0.2.0 
      │ │ │   │ └── repeat-element@1.1.2 
      │ │ │   ├─┬ expand-brackets@0.1.5 
      │ │ │   │ └── is-posix-bracket@0.1.1 
      │ │ │   ├── extglob@0.3.2 
      │ │ │   ├── filename-regex@2.0.0 
      │ │ │   ├─┬ kind-of@3.1.0 
      │ │ │   │ └── is-buffer@1.1.4 
      │ │ │   ├── normalize-path@2.0.1 
      │ │ │   ├─┬ object.omit@2.0.1 
      │ │ │   │ ├─┬ for-own@0.1.4 
      │ │ │   │ │ └── for-in@0.1.6 
      │ │ │   │ └── is-extendable@0.1.1 
      │ │ │   ├─┬ parse-glob@3.0.4 
      │ │ │   │ ├── glob-base@0.3.0 
      │ │ │   │ └── is-dotfile@1.0.2 
      │ │ │   └─┬ regex-cache@0.4.3 
      │ │ │     ├── is-equal-shallow@0.1.3 
      │ │ │     └── is-primitive@2.0.0 
      │ │ ├── async-each@1.0.1 
      │ │ ├── glob-parent@2.0.0 
      │ │ ├── inherits@2.0.3 
      │ │ ├─┬ is-binary-path@1.0.1 
      │ │ │ └── binary-extensions@1.8.0 
      │ │ ├─┬ is-glob@2.0.1 
      │ │ │ └── is-extglob@1.0.0 
      │ │ ├── path-is-absolute@1.0.1 
      │ │ └─┬ readdirp@2.1.0 
      │ │   ├─┬ minimatch@3.0.3 
      │ │   │ └─┬ brace-expansion@1.1.6 
      │ │   │   ├── balanced-match@0.4.2 
      │ │   │   └── concat-map@0.0.1 
      │ │   ├─┬ readable-stream@2.2.2 
      │ │   │ ├── buffer-shims@1.0.0 
      │ │   │ ├── core-util-is@1.0.2 
      │ │   │ ├── isarray@1.0.0 
      │ │   │ ├── process-nextick-args@1.0.7 
      │ │   │ ├── string_decoder@0.10.31 
      │ │   │ └── util-deprecate@1.0.2 
      │ │   └── set-immediate-shim@1.0.1 
      │ └── graceful-fs@4.1.11 
      ├─┬ hexo-log@0.1.2 
      │ └─┬ bunyan@1.8.5 
      │   ├─┬ dtrace-provider@0.8.0 
      │   │ └── nan@2.5.0 
      │   ├── moment@2.17.1 
      │   ├─┬ mv@2.1.1 
      │   │ ├─┬ mkdirp@0.5.1 
      │   │ │ └── minimist@0.0.8 
      │   │ ├── ncp@2.0.0 
      │   │ └─┬ rimraf@2.4.5 
      │   │   └─┬ glob@6.0.4 
      │   │     ├─┬ inflight@1.0.6 
      │   │     │ └── wrappy@1.0.2 
      │   │     └── once@1.4.0 
      │   └── safe-json-stringify@1.0.3 
      ├─┬ hexo-util@0.6.0 
      │ ├─┬ camel-case@3.0.0 
      │ │ ├─┬ no-case@2.3.1 
      │ │ │ └── lower-case@1.1.3 
      │ │ └── upper-case@1.1.3 
      │ ├─┬ cross-spawn@4.0.2 
      │ │ ├─┬ lru-cache@4.0.2 
      │ │ │ ├── pseudomap@1.0.2 
      │ │ │ └── yallist@2.0.0 
      │ │ └─┬ which@1.2.12 
      │ │   └── isexe@1.1.2 
      │ ├── highlight.js@9.9.0 
      │ ├── html-entities@1.2.0 
      │ └── striptags@2.1.1 
      ├── minimist@1.2.0 
      ├── object-assign@4.1.0 
      └─┬ tildify@1.2.0 
        └── os-homedir@1.0.2 
    
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    [root@center-linux ~]# 
    [root@center-linux ~]#

    4. 建站:

    [root@center-linux ~]# mkdir -p /hexo_web_data/adamhuan_blog
    [root@center-linux ~]# ls -ltr /hexo_web_data/adamhuan_blog/
    total 0
    [root@center-linux ~]# 
    [root@center-linux ~]# hexo init /hexo_web_data/adamhuan_blog/
    INFO  Cloning hexo-starter to /hexo_web_data/adamhuan_blog
    Cloning into '/hexo_web_data/adamhuan_blog'...
    remote: Counting objects: 53, done.
    remote: Total 53 (delta 0), reused 0 (delta 0), pack-reused 53
    Unpacking objects: 100% (53/53), done.
    Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'
    Cloning into 'themes/landscape'...
    remote: Counting objects: 756, done.
    remote: Total 756 (delta 0), reused 0 (delta 0), pack-reused 756
    Receiving objects: 100% (756/756), 2.53 MiB | 58.00 KiB/s, done.
    Resolving deltas: 100% (387/387), done.
    Submodule path 'themes/landscape': checked out 'decdc2d9956776cbe95420ae94bac87e22468d38'
    INFO  Install dependencies
    npm WARN deprecated swig@1.4.2: This package is no longer maintained
    npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
    npm WARN prefer global marked@0.3.6 should be installed with -g
    
    > dtrace-provider@0.8.0 install /hexo_web_data/adamhuan_blog/node_modules/dtrace-provider
    > node scripts/install.js
    
    
    > hexo-util@0.6.0 postinstall /hexo_web_data/adamhuan_blog/node_modules/hexo-util
    > npm run build:highlight
    
    
    > hexo-util@0.6.0 build:highlight /hexo_web_data/adamhuan_blog/node_modules/hexo-util
    > node scripts/build_highlight_alias.js > highlight_alias.json
    
    hexo-site@0.0.0 /hexo_web_data/adamhuan_blog
    ├─┬ hexo@3.2.2 
    │ ├── abbrev@1.0.9 
    │ ├── archy@1.0.0 
    │ ├── bluebird@3.4.7 
    │ ├─┬ chalk@1.1.3 
    │ │ ├── ansi-styles@2.2.1 
    │ │ ├── escape-string-regexp@1.0.5 
    │ │ ├─┬ has-ansi@2.0.0 
    │ │ │ └── ansi-regex@2.0.0 
    │ │ ├── strip-ansi@3.0.1 
    │ │ └── supports-color@2.0.0 
    │ ├─┬ cheerio@0.20.0 
    │ │ ├─┬ css-select@1.2.0 
    │ │ │ ├── boolbase@1.0.0 
    │ │ │ ├── css-what@2.1.0 
    │ │ │ ├── domutils@1.5.1 
    │ │ │ └── nth-check@1.0.1 
    │ │ ├─┬ dom-serializer@0.1.0 
    │ │ │ └── domelementtype@1.1.3 
    │ │ ├── entities@1.1.1 
    │ │ ├─┬ htmlparser2@3.8.3 
    │ │ │ ├── domelementtype@1.3.0 
    │ │ │ ├── domhandler@2.3.0 
    │ │ │ ├── entities@1.0.0 
    │ │ │ └─┬ readable-stream@1.1.14 
    │ │ │   ├── core-util-is@1.0.2 
    │ │ │   ├── isarray@0.0.1 
    │ │ │   └── string_decoder@0.10.31 
    │ │ └─┬ jsdom@7.2.2 
    │ │   ├── abab@1.0.3 
    │ │   ├── acorn@2.7.0 
    │ │   ├── acorn-globals@1.0.9 
    │ │   ├── cssom@0.3.1 
    │ │   ├── cssstyle@0.2.37 
    │ │   ├─┬ escodegen@1.8.1 
    │ │   │ ├── estraverse@1.9.3 
    │ │   │ ├── esutils@2.0.2 
    │ │   │ ├─┬ optionator@0.8.2 
    │ │   │ │ ├── deep-is@0.1.3 
    │ │   │ │ ├── fast-levenshtein@2.0.6 
    │ │   │ │ ├── levn@0.3.0 
    │ │   │ │ ├── prelude-ls@1.1.2 
    │ │   │ │ ├── type-check@0.3.2 
    │ │   │ │ └── wordwrap@1.0.0 
    │ │   │ └── source-map@0.2.0 
    │ │   ├── nwmatcher@1.3.9 
    │ │   ├── parse5@1.5.1 
    │ │   ├─┬ request@2.79.0 
    │ │   │ ├── aws-sign2@0.6.0 
    │ │   │ ├── aws4@1.5.0 
    │ │   │ ├── caseless@0.11.0 
    │ │   │ ├─┬ combined-stream@1.0.5 
    │ │   │ │ └── delayed-stream@1.0.0 
    │ │   │ ├── extend@3.0.0 
    │ │   │ ├── forever-agent@0.6.1 
    │ │   │ ├─┬ form-data@2.1.2 
    │ │   │ │ └── asynckit@0.4.0 
    │ │   │ ├─┬ har-validator@2.0.6 
    │ │   │ │ ├─┬ commander@2.9.0 
    │ │   │ │ │ └── graceful-readlink@1.0.1 
    │ │   │ │ └─┬ is-my-json-valid@2.15.0 
    │ │   │ │   ├── generate-function@2.0.0 
    │ │   │ │   ├─┬ generate-object-property@1.2.0 
    │ │   │ │   │ └── is-property@1.0.2 
    │ │   │ │   ├── jsonpointer@4.0.1 
    │ │   │ │   └── xtend@4.0.1 
    │ │   │ ├─┬ hawk@3.1.3 
    │ │   │ │ ├── boom@2.10.1 
    │ │   │ │ ├── cryptiles@2.0.5 
    │ │   │ │ ├── hoek@2.16.3 
    │ │   │ │ └── sntp@1.0.9 
    │ │   │ ├─┬ http-signature@1.1.1 
    │ │   │ │ ├── assert-plus@0.2.0 
    │ │   │ │ ├─┬ jsprim@1.3.1 
    │ │   │ │ │ ├── extsprintf@1.0.2 
    │ │   │ │ │ ├── json-schema@0.2.3 
    │ │   │ │ │ └── verror@1.3.6 
    │ │   │ │ └─┬ sshpk@1.10.1 
    │ │   │ │   ├── asn1@0.2.3 
    │ │   │ │   ├── assert-plus@1.0.0 
    │ │   │ │   ├── bcrypt-pbkdf@1.0.0 
    │ │   │ │   ├─┬ dashdash@1.14.1 
    │ │   │ │   │ └── assert-plus@1.0.0 
    │ │   │ │   ├── ecc-jsbn@0.1.1 
    │ │   │ │   ├─┬ getpass@0.1.6 
    │ │   │ │   │ └── assert-plus@1.0.0 
    │ │   │ │   ├── jodid25519@1.0.2 
    │ │   │ │   ├── jsbn@0.1.0 
    │ │   │ │   └── tweetnacl@0.14.5 
    │ │   │ ├── is-typedarray@1.0.0 
    │ │   │ ├── isstream@0.1.2 
    │ │   │ ├── json-stringify-safe@5.0.1 
    │ │   │ ├── oauth-sign@0.8.2 
    │ │   │ ├── qs@6.3.0 
    │ │   │ ├── stringstream@0.0.5 
    │ │   │ ├── tunnel-agent@0.4.3 
    │ │   │ └── uuid@3.0.1 
    │ │   ├── sax@1.2.1 
    │ │   ├── symbol-tree@3.2.1 
    │ │   ├─┬ tough-cookie@2.3.2 
    │ │   │ └── punycode@1.4.1 
    │ │   ├── webidl-conversions@2.0.1 
    │ │   ├─┬ whatwg-url-compat@0.6.5 
    │ │   │ └── tr46@0.0.3 
    │ │   └── xml-name-validator@2.0.1 
    │ ├─┬ hexo-cli@1.0.2 
    │ │ └── minimist@1.2.0 
    │ ├── hexo-front-matter@0.2.3 
    │ ├─┬ hexo-fs@0.1.6 
    │ │ ├─┬ chokidar@1.6.1 
    │ │ │ ├─┬ anymatch@1.3.0 
    │ │ │ │ ├── arrify@1.0.1 
    │ │ │ │ └─┬ micromatch@2.3.11 
    │ │ │ │   ├─┬ arr-diff@2.0.0 
    │ │ │ │   │ └── arr-flatten@1.0.1 
    │ │ │ │   ├── array-unique@0.2.1 
    │ │ │ │   ├─┬ braces@1.8.5 
    │ │ │ │   │ ├─┬ expand-range@1.8.2 
    │ │ │ │   │ │ └─┬ fill-range@2.2.3 
    │ │ │ │   │ │   ├── is-number@2.1.0 
    │ │ │ │   │ │   ├─┬ isobject@2.1.0 
    │ │ │ │   │ │   │ └── isarray@1.0.0 
    │ │ │ │   │ │   ├── randomatic@1.1.6 
    │ │ │ │   │ │   └── repeat-string@1.6.1 
    │ │ │ │   │ ├── preserve@0.2.0 
    │ │ │ │   │ └── repeat-element@1.1.2 
    │ │ │ │   ├─┬ expand-brackets@0.1.5 
    │ │ │ │   │ └── is-posix-bracket@0.1.1 
    │ │ │ │   ├── extglob@0.3.2 
    │ │ │ │   ├── filename-regex@2.0.0 
    │ │ │ │   ├─┬ kind-of@3.1.0 
    │ │ │ │   │ └── is-buffer@1.1.4 
    │ │ │ │   ├── normalize-path@2.0.1 
    │ │ │ │   ├─┬ object.omit@2.0.1 
    │ │ │ │   │ ├─┬ for-own@0.1.4 
    │ │ │ │   │ │ └── for-in@0.1.6 
    │ │ │ │   │ └── is-extendable@0.1.1 
    │ │ │ │   ├─┬ parse-glob@3.0.4 
    │ │ │ │   │ ├── glob-base@0.3.0 
    │ │ │ │   │ └── is-dotfile@1.0.2 
    │ │ │ │   └─┬ regex-cache@0.4.3 
    │ │ │ │     ├── is-equal-shallow@0.1.3 
    │ │ │ │     └── is-primitive@2.0.0 
    │ │ │ ├── async-each@1.0.1 
    │ │ │ ├── glob-parent@2.0.0 
    │ │ │ ├── inherits@2.0.3 
    │ │ │ ├─┬ is-binary-path@1.0.1 
    │ │ │ │ └── binary-extensions@1.8.0 
    │ │ │ ├─┬ is-glob@2.0.1 
    │ │ │ │ └── is-extglob@1.0.0 
    │ │ │ ├── path-is-absolute@1.0.1 
    │ │ │ └─┬ readdirp@2.1.0 
    │ │ │   ├─┬ readable-stream@2.2.2 
    │ │ │   │ ├── buffer-shims@1.0.0 
    │ │ │   │ ├── isarray@1.0.0 
    │ │ │   │ ├── process-nextick-args@1.0.7 
    │ │ │   │ └── util-deprecate@1.0.2 
    │ │ │   └── set-immediate-shim@1.0.1 
    │ │ └── graceful-fs@4.1.11 
    │ ├─┬ hexo-i18n@0.2.1 
    │ │ └── sprintf-js@1.0.3 
    │ ├─┬ hexo-log@0.1.2 
    │ │ └─┬ bunyan@1.8.5 
    │ │   ├─┬ dtrace-provider@0.8.0 
    │ │   │ └── nan@2.5.0 
    │ │   ├─┬ mv@2.1.1 
    │ │   │ ├── ncp@2.0.0 
    │ │   │ └─┬ rimraf@2.4.5 
    │ │   │   └── glob@6.0.4 
    │ │   └── safe-json-stringify@1.0.3 
    │ ├─┬ hexo-util@0.6.0 
    │ │ ├─┬ camel-case@3.0.0 
    │ │ │ ├─┬ no-case@2.3.1 
    │ │ │ │ └── lower-case@1.1.3 
    │ │ │ └── upper-case@1.1.3 
    │ │ ├─┬ cross-spawn@4.0.2 
    │ │ │ ├─┬ lru-cache@4.0.2 
    │ │ │ │ ├── pseudomap@1.0.2 
    │ │ │ │ └── yallist@2.0.0 
    │ │ │ └─┬ which@1.2.12 
    │ │ │   └── isexe@1.1.2 
    │ │ ├── highlight.js@9.9.0 
    │ │ ├── html-entities@1.2.0 
    │ │ └── striptags@2.1.1 
    │ ├─┬ js-yaml@3.7.0 
    │ │ ├── argparse@1.0.9 
    │ │ └── esprima@2.7.3 
    │ ├── lodash@4.17.4 
    │ ├─┬ minimatch@3.0.3 
    │ │ └─┬ brace-expansion@1.1.6 
    │ │   ├── balanced-match@0.4.2 
    │ │   └── concat-map@0.0.1 
    │ ├── moment@2.13.0 
    │ ├── moment-timezone@0.5.11 
    │ ├─┬ nunjucks@2.5.2 
    │ │ ├── asap@2.0.5 
    │ │ └─┬ yargs@3.32.0 
    │ │   ├── camelcase@2.1.1 
    │ │   ├─┬ cliui@3.2.0 
    │ │   │ └── wrap-ansi@2.1.0 
    │ │   ├── decamelize@1.2.0 
    │ │   ├─┬ os-locale@1.4.0 
    │ │   │ └─┬ lcid@1.0.0 
    │ │   │   └── invert-kv@1.0.0 
    │ │   ├─┬ string-width@1.0.2 
    │ │   │ ├── code-point-at@1.1.0 
    │ │   │ └─┬ is-fullwidth-code-point@1.0.0 
    │ │   │   └── number-is-nan@1.0.1 
    │ │   ├── window-size@0.1.4 
    │ │   └── y18n@3.2.1 
    │ ├── pretty-hrtime@1.0.3 
    │ ├─┬ strip-indent@1.0.1 
    │ │ └── get-stdin@4.0.1 
    │ ├─┬ swig@1.4.2 
    │ │ ├─┬ optimist@0.6.1 
    │ │ │ ├── minimist@0.0.10 
    │ │ │ └── wordwrap@0.0.3 
    │ │ └─┬ uglify-js@2.4.24 
    │ │   ├── async@0.2.10 
    │ │   ├── source-map@0.1.34 
    │ │   ├── uglify-to-browserify@1.0.2 
    │ │   └─┬ yargs@3.5.4 
    │ │     ├── camelcase@1.2.1 
    │ │     ├── window-size@0.1.0 
    │ │     └── wordwrap@0.0.2 
    │ ├─┬ swig-extras@0.0.1 
    │ │ └─┬ markdown@0.5.0 
    │ │   └── nopt@2.1.2 
    │ ├── text-table@0.2.0 
    │ ├─┬ tildify@1.2.0 
    │ │ └── os-homedir@1.0.2 
    │ ├── titlecase@1.1.2 
    │ └─┬ warehouse@2.2.0 
    │   ├─┬ cuid@1.3.8 
    │   │ ├── browser-fingerprint@0.0.1 
    │   │ ├── core-js@1.2.7 
    │   │ └── node-fingerprint@0.0.2 
    │   ├─┬ is-plain-object@2.0.1 
    │   │ └── isobject@1.0.2 
    │   └─┬ JSONStream@1.3.0 
    │     ├── jsonparse@1.2.0 
    │     └── through@2.3.8 
    ├─┬ hexo-generator-archive@0.1.4 
    │ ├─┬ hexo-pagination@0.0.2 
    │ │ └── utils-merge@1.0.0 
    │ └── object-assign@2.1.1 
    ├─┬ hexo-generator-category@0.1.3 
    │ └── object-assign@2.1.1 
    ├─┬ hexo-generator-index@0.2.0 
    │ └── object-assign@4.1.0 
    ├── hexo-generator-tag@0.2.0 
    ├─┬ hexo-renderer-ejs@0.2.0 
    │ └── ejs@1.0.0 
    ├─┬ hexo-renderer-marked@0.2.11 
    │ └── marked@0.3.6 
    ├─┬ hexo-renderer-stylus@0.3.1 
    │ ├─┬ nib@1.1.2 
    │ │ └─┬ stylus@0.54.5 
    │ │   ├─┬ glob@7.0.6 
    │ │   │ ├── fs.realpath@1.0.0 
    │ │   │ ├─┬ inflight@1.0.6 
    │ │   │ │ └── wrappy@1.0.2 
    │ │   │ └── once@1.4.0 
    │ │   ├── sax@0.5.8 
    │ │   └── source-map@0.1.43 
    │ └─┬ stylus@0.53.0 
    │   ├── css-parse@1.7.0 
    │   ├─┬ debug@2.6.0 
    │   │ └── ms@0.7.2 
    │   ├─┬ glob@3.2.11 
    │   │ └─┬ minimatch@0.3.0 
    │   │   ├── lru-cache@2.7.3 
    │   │   └── sigmund@1.0.1 
    │   ├─┬ mkdirp@0.5.1 
    │   │ └── minimist@0.0.8 
    │   ├── sax@0.5.8 
    │   └─┬ source-map@0.1.43 
    │     └── amdefine@1.0.1 
    └─┬ hexo-server@0.2.0 
      ├─┬ compression@1.6.2 
      │ ├─┬ accepts@1.3.3 
      │ │ ├── mime-types@2.1.13 
      │ │ └── negotiator@0.6.1 
      │ ├── bytes@2.3.0 
      │ ├─┬ compressible@2.0.9 
      │ │ └── mime-db@1.25.0 
      │ ├─┬ debug@2.2.0 
      │ │ └── ms@0.7.1 
      │ ├── on-headers@1.0.1 
      │ └── vary@1.1.0 
      ├─┬ connect@3.5.0 
      │ ├─┬ debug@2.2.0 
      │ │ └── ms@0.7.1 
      │ ├─┬ finalhandler@0.5.0 
      │ │ ├─┬ debug@2.2.0 
      │ │ │ └── ms@0.7.1 
      │ │ ├── statuses@1.3.1 
      │ │ └── unpipe@1.0.0 
      │ └── parseurl@1.3.1 
      ├── mime@1.3.4 
      ├─┬ morgan@1.7.0 
      │ ├── basic-auth@1.0.4 
      │ ├─┬ debug@2.2.0 
      │ │ └── ms@0.7.1 
      │ ├── depd@1.1.0 
      │ └─┬ on-finished@2.3.0 
      │   └── ee-first@1.1.1 
      ├─┬ opn@4.0.2 
      │ └─┬ pinkie-promise@2.0.1 
      │   └── pinkie@2.0.4 
      └─┬ serve-static@1.11.1 
        ├── encodeurl@1.0.1 
        ├── escape-html@1.0.3 
        └─┬ send@0.14.1 
          ├── debug@2.2.0 
          ├── destroy@1.0.4 
          ├── etag@1.7.0 
          ├── fresh@0.3.0 
          ├─┬ http-errors@1.5.1 
          │ └── setprototypeof@1.0.2 
          ├── ms@0.7.1 
          └── range-parser@1.2.0 
    
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    INFO  Start blogging with Hexo!
    [root@center-linux ~]# 
    [root@center-linux ~]# cd /hexo_web_data/adamhuan_blog/
    [root@center-linux adamhuan_blog]# ls
    _config.yml  node_modules  package.json  scaffolds  source  themes
    [root@center-linux adamhuan_blog]# 
    [root@center-linux adamhuan_blog]# npm install
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    [root@center-linux adamhuan_blog]# 
    [root@center-linux adamhuan_blog]#

    这时候,目录的情况是这样的:

    [root@center-linux nvm]# ls -ltr /hexo_web_data/adamhuan_blog/
    total 20
    drwxr-xr-x.   3 root root   19 Jan 14 00:48 source
    drwxr-xr-x.   2 root root   49 Jan 14 00:48 scaffolds
    -rw-r--r--.   1 root root  443 Jan 14 00:48 package.json
    -rw-r--r--.   1 root root 1483 Jan 14 00:48 _config.yml
    drwxr-xr-x.   3 root root   22 Jan 14 00:48 themes
    drwxr-xr-x. 286 root root 8192 Jan 14 01:14 node_modules
    [root@center-linux nvm]# 
    [root@center-linux nvm]# du -sh /hexo_web_data/adamhuan_blog/
    47M     /hexo_web_data/adamhuan_blog/
    [root@center-linux nvm]#

    5. 配置:
    目录:

    [root@center-linux nvm]# cd /hexo_web_data/
    [root@center-linux hexo_web_data]# ls
    adamhuan_blog
    [root@center-linux hexo_web_data]# cd adamhuan_blog/
    [root@center-linux adamhuan_blog]# ls
    _config.yml  node_modules  package.json  scaffolds  source  themes
    [root@center-linux adamhuan_blog]# 
    [root@center-linux adamhuan_blog]# mkdir /backup_me
    [root@center-linux adamhuan_blog]# cp _config.yml /backup_me/
    [root@center-linux adamhuan_blog]# cp package.json /backup_me/
    [root@center-linux adamhuan_blog]# 
    [root@center-linux adamhuan_blog]# ls -ltr /backup_me/
    total 8
    -rw-r--r--. 1 root root 1483 Jan 14 01:20 _config.yml
    -rw-r--r--. 1 root root  443 Jan 14 01:23 package.json
    [root@center-linux adamhuan_blog]#

    配置:_config.yml

    [root@center-linux adamhuan_blog]# cat _config.yml 
    # Hexo Configuration
    ## Docs: https://hexo.io/docs/configuration.html
    ## Source: https://github.com/hexojs/hexo/
    
    # Site
    title: Adamhuan's Hexo
    subtitle:
    description:
    author: Adamhuan
    language: Chinese
    timezone: Asia/Shanghai
    
    # URL
    ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
    url: http://192.168.19.137
    root: /
    permalink: :year/:month/:day/:title/
    permalink_defaults:
    
    # Directory
    source_dir: source
    public_dir: public
    tag_dir: tags
    archive_dir: archives
    category_dir: categories
    code_dir: downloads/code
    i18n_dir: :lang
    skip_render:
    
    # Writing
    new_post_name: :title.md # File name of new posts
    default_layout: post
    titlecase: false # Transform title into titlecase
    external_link: true # Open external links in new tab
    filename_case: 0
    render_drafts: false
    post_asset_folder: false
    relative_link: false
    future: true
    highlight:
      enable: true
      line_number: true
      auto_detect: false
      tab_replace:
    
    # Category & Tag
    default_category: uncategorized
    category_map:
    tag_map:
    
    # Date / Time format
    ## Hexo uses Moment.js to parse and display date
    ## You can customize the date format as defined in
    ## http://momentjs.com/docs/#/displaying/format/
    date_format: YYYY-MM-DD
    time_format: HH:mm:ss
    
    # Pagination
    ## Set per_page to 0 to disable pagination
    per_page: 10
    pagination_dir: page
    
    # Extensions
    ## Plugins: https://hexo.io/plugins/
    ## Themes: https://hexo.io/themes/
    theme: landscape
    
    # Deployment
    ## Docs: https://hexo.io/docs/deployment.html
    deploy:
      type:
    [root@center-linux adamhuan_blog]#

    创建一篇文章:

    [root@center-linux adamhuan_blog]# ls -ltr
    total 20
    drwxr-xr-x.   3 root root   19 Jan 14 00:48 source
    drwxr-xr-x.   2 root root   49 Jan 14 00:48 scaffolds
    -rw-r--r--.   1 root root  443 Jan 14 00:48 package.json
    drwxr-xr-x.   3 root root   22 Jan 14 00:48 themes
    drwxr-xr-x. 286 root root 8192 Jan 14 01:19 node_modules
    -rw-r--r--.   1 root root 1513 Jan 14 01:27 _config.yml
    [root@center-linux adamhuan_blog]# 
    [root@center-linux adamhuan_blog]# hexo new "hello_world"
    INFO  Created: /hexo_web_data/adamhuan_blog/source/_posts/hello-world-1.md
    [root@center-linux adamhuan_blog]# 
    [root@center-linux adamhuan_blog]# hexo generate
    INFO  Start processing
    INFO  Files loaded in 260 ms
    INFO  Generated: 2017/01/14/hello-world/index.html
    INFO  Generated: archives/index.html
    INFO  Generated: archives/2017/index.html
    INFO  Generated: archives/2017/01/index.html
    INFO  Generated: index.html
    INFO  Generated: 2017/01/14/hello-world-1/index.html
    INFO  6 files generated in 138 ms
    [root@center-linux adamhuan_blog]#

    启动服务器:

    [root@center-linux adamhuan_blog]# hexo server
    INFO  Start processing
    INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

    这样,就可以访问HEXO了:

    文章(POST)都被存储在了【source】目录中:

    [root@center-linux _posts]# pwd
    /hexo_web_data/adamhuan_blog/source/_posts
    [root@center-linux _posts]# 
    [root@center-linux _posts]# ls -ltr
    total 12
    -rw-r--r--. 1 root root 826 Jan 14 02:02 hello-world.md
    -rw-r--r--. 1 root root 278 Jan 14 02:24 Good-Night.md
    -rw-r--r--. 1 root root 310 Jan 14 02:36 Web-APP-on-Linux.md
    [root@center-linux _posts]#

    关于HEXO,还有更多的使用方法与命令,可以参考下面的文档:
    https://hexo.io/zh-cn/docs/commands.html

    ————————
    Done。



沪ICP备19023445号-2号
友情链接