基于Hexo搭建个人博客

YeLuo lol

官网 & Github

部署Hexo

安装Git(基于 第三方isu源)
1
2
3
4
5
6
7
8
9
10
11
12
# 开始卸载旧版本
yum remove -y git

# 安装 ius-release 包 epel-release包
yum install -y \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# 安装 git
yum install -y git236

# 验证
git --version
安装NodeJS
1
2
3
4
# 安装 node
yum install -y nodejs
# 安装 npm
yum install -y npm
安装 Hexo
1
2
3
4
# 安装 hexo-cli
npm install -g hexo-cli
# 配置环境变量
echo 'PATH="$PATH:./node_modules/.bin"' >> ~/.profile
初始化博客
1
2
3
hexo init blog
cd blog
npm install
运行
1
hexo g -s
后台运行Hexo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 安装 pm2
npm install -g pm2

# 写入run.js
tee run.js <<-'EOF'
const { exec } = require('child_process')
exec('hexo server',(error, stdout, stderr) => {
if(error){
console.log('exec error: ${error}')
return
}
console.log('stdout: ${stdout}');
console.log('stderr: ${stderr}');
})
EOF

# 使用pm2运行
pm2 start run.js
# 其他
pm2 list
pm2 stop run.js
pm2 restart run.js
安装Redefine主题
1
2
3
4
5
6
7
8
9
10
# git方式安装
git clone https://github.com/EvanNotFound/hexo-theme-redefine.git themes/redefine

# 修改Hexo根目录中 _config.yml
theme: redefine

# 创建主题配置文件 在Hexo根目录中创建 _config.redefine.yml 修改成一下链接代码
https://github.com/EvanNotFound/hexo-theme-redefine/blob/main/_config.yml

# 后续配置 参考官方文档

结束

  • 本文标题:基于Hexo搭建个人博客
  • 本文作者:YeLuo
  • 创建时间:2023-03-01 00:00:00
  • 本文链接:https://www.zhcoder.com/2023/03/01/init/
  • 版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!