ubuntu下搭建hexo个人博客
Hexo install
0. update & upgrade system packages
First, ensure the system packages are up to date
sudo apt-get update && sudo apt-get upgrade
Second, if you want to create a repostory on github, you should install Git.
sudo apt-get install git
1. install node.js
Install node.js using nvm(node.js version manager)
1. Install essential environment lib
sudo apt-get install build-essential libssl-dev
2. Pull down the nvm installation script from the nvm's GitHub page and install nvm
using cURL:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
using Wget:
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
or download zip file and unzip
unzip -o nvm-master.zip
cd nvm-master
./install.sh
3. Then update profile
source ~/.profile
4. Install node.js
Find out the versions of Node.js that are available for installation
nvm ls-remote
......
v6.5.0
v6.6.0
v6.7.0
v6.8.0
v6.8.1
v6.9.0 (LTS: Boron)
v6.9.1 (LTS: Boron)
v6.9.2 (LTS: Boron)
v6.9.3 (LTS: Boron)
v6.9.4 (LTS: Boron)
v6.9.5 (LTS: Boron)
v6.10.0 (LTS: Boron)
v6.10.1 (Latest LTS: Boron)
v7.0.0
......
As we see, the Latest LTS is 6.10.1, we can install that and explicitly declare the use version is 6.10.1
nvm install 6.10.1
nvm use 6.10.1
If you have multiple Node.js versions, you can see what is installed by typing:
nvm ls
If you wish to default one of the versions, you can type:
nvm alias default 6.10.1
This version will be automatically selected when a new session spawnss. You can also reference it by the alias like this:
nvm use default
2. Install hexo
Using the npm(node.js package manager) to install hexo.
1. Install hexo-cli , the most important and provides the core Hexo commands.
npm install hexo-cli -g
2. Install hexo-server , the build-in server.
npm install hexo-server -g
install package throw error: sh: 1: node: Permission denied
Fix:
npm config set unsafe-perm true
Explain:
unsafe-perm: false(default) if running as root, true otherwise. Set to true to suppress the UID/GID switching when running
3. Initialize hexo home directory and install blog project.
mkdir blog_home
hexo init blog_home/
cd blog_home
npm install
```