Nodejs

Install nodejs for running hexo blog framework.
First make sure you have curl, because we need to install nodejs through nodesource.

1
sudo apt-get install -y curl

curl to download the setup shell script and then run the script.

1
2
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh

And then install nodejs.

1
sudo apt-get install -y nodejs

Use the following command to check if your nodejs install correctly.

1
node -v

Hexo

We need to install hexo-cli, but for the people who is super familar with hexo, they also can only install hexo.

1
2
npm install -g hexo-cli
npm install hexo

If you find the following warning, it means that you run with a normal user, but npm install need a root user, so please use sudo.

1
2
3
4
5
6
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.

For easily run command with in linux, we can add npm node_modules to environment variable.

1
echo 'PATH="$PATH:./node_modules/.bin"' >> ~/.profile

After install hexo, we can init the basic files in our blog directory. And then install the blog.

1
2
3
hexo init dreamking60-blog
cd dreamking60-blog
npm install

The target blog directory file may be as following, this is using the [[tree]] command.

1
2
3
4
5
6
7
8
├── _config.landscape.yml
├── _config.yml
├── node_modules
├── package-lock.json
├── package.json
├── scaffolds
├── source
└── themes

Stellar

Go into our blog directory and then install the theme.
Install hexo-theme-steller by the following command.

1
npm i hexo-theme-stellar

And then modfiy the _config.yam file. Change the theme to stellar

1
theme: stellar

According to the hexo offical document to configure the blog website.

Running

Running the server can along the hexo server command.

1
hexo server -p 80

If we want to make it continue to run on our server. We should use the pm2 to manage the server.

1
2
npm install -g pm2
pm2 start "hexo server -p 20" --name hexo

And also remember to add the following command for futher configuration.

1
2
pm2 startup
pm2 save

Add Comment System

In the _config.stellar.yml configure file,

Blog Update

Anytime you update the settings of the blog. Restart the pm2 to enable the new setting.

1
sudo pm2 restart hexo