安装git

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#sudo 权限执行
wget https://github.com/git/git/archive/v2.35.1.tar.gz
tar -zxvf git-2.35.1.tar.gz
#安装依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
#卸载自动安装的git版本太低
yum remove git
#执行编译
cd git-2.35.1
make prefix=/usr/local/git all
#安装Git
sudo make prefix=/usr/local/git install
#编辑环境变量配置
vim /etc/profile

PATH=$PATH:/usr/local/git/bin
export PATH
#初始化配置文件
source /etc/profile
#验证
git --version

安装Nodejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Linux安装Nodejs
# 获取二进制文件
wget https://nodejs.org/dist/v14.14.0/node-v14.14.0-linux-x64.tar.xz

# Unzip the binary archive 创建文件目录
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-v14.14.0-linux-x64.tar.xz -C /usr/local/lib/nodejs

# 设置环境变量 ~/.profile, 创建文件
vi ~/.profile

VERSION=v14.14.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH

# 加载 /.profile配置文件
vi ~/.bashrc

. ~/.profile

# 验证
node -v
npm version
npx -v

Hexo配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 安装Hexo 这里需要切换到root用户或者使用sudo权限
npm install hexo-cli -g

# 把hexo命令添加到全局:hexo在nodejs的nodejs/bin目录可以找到hexo命令,方式是采用软连接:
ln -s /usr/local/lib/nodejs/node-v16.14.0-linux-x64/bin/hexo /usr/local/bin/hexo

#验证
hexo

#部署
mkdir hexo
hexo init
npm install

#启动本地服务:
hexo s

# 替换已有的Hexo配置 覆盖文件
# 文件地址 https://fengfeng.lanzouj.com/iCJC800ugubi
unzip -o hexo.zip -d hexo

使用基本命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 创建新文件
hexo new post "new"

# 上传文件
hexo clean
hexo g
hexo d

# or 创建新文件 bash new.sh

# or 上传文件 bash up.sh


安装hexo到Linux并部署到Gitee

接上文安装Git和Nodejs之后的记录
<! – more –>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#更换国内淘宝源 npm    其实不能用,我也不知道为啥
npm config set registry https://registry.npm.taobao.org

// 配置后可通过下面方式来验证是否成功
npm config get registry
// 或
npm info express

# 真SB 不好用
# 注:依赖hexo-renderer-sass安装时容易报错,很可能是国内网络问题,请尝试使用代理或者切换至NPM的国内镜像源安装。
# 最终解决方案是安装python 2.7
# RockyLinux中安装python2.7
dnf install python2
sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 安装 hexo 主题与渲染器 到hexo目录下


git clone https://github.com/tufu9441/maupassant-hexo.git themes/maupassant

npm install hexo-renderer-pug --save
npm install hexo-renderer-sass --save

# 注:依赖hexo-renderer-sass安装时容易报错,很可能是国内网络问题,请尝试使用代理或者切换至NPM的国内镜像源安装。
# npm install dart-sass --save
# 我选择使用 dart-sass 来代替 hexo-renderer-sass
# 编辑Hexo目录下的 _config.yml,将theme的值改为maupassant。
# 最终解决方案是安装python 2.7 node版本14.14.0
# RockyLinux中安装python2.7
dnf install python2
ln -s /usr/local/python-2.7.9/bin/python2.7 /usr/bin/python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 部署到gitee 在Blog目录下安装一个hexo部署插件
npm install --save hexo-deployer-git

# 创建电脑公玥
ssh-keygen -t rsa -C "git@gitee.com"
# 接着完成三次回车,即可生成 ssh密钥

# 获取生成的 public 密钥
cat ~/.ssh/id_rsa.pub
# 复制生成后的 ssh 密钥,通过仓库主页 「管理」—「部署公钥管理」—「添加部署个人公钥」, 添加生成的 public 密钥


# 编辑Hexo目录下的 _config.yml,
# Docs: https://hexo.io/docs/one-command-deployment
# git@gitee.com:用户名/仓库名.git
deploy:
type: git
repo: git@gitee.com:Peaky2022/Peaky.git
branch: master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
npm install hexo-abbrlink --save
npm install valine --save
npm install hexo-wordcount
npm install hexo-generator-search
npm install hexo-renderer-sass --save

# 永久地址插件配置
permalink: posts/:abbrlink.html
abbrlink:
alg: crc32 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex
#add v7.8.0
permalink_defaults:
pretty_urls:
trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks


部署到githubpage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 创建仓库 例如我的用户名 Notes366 则创建一个仓库 notes366.github.io   大小写无关 部署后访问 https://notes366.github.io/
# git config --global user.email "xiaozhenniaini@gmail.com"
# git config --global user.name "peaky"
#仓库设置默认Branch为 master
# 编辑Hexo目录下的 _config.yml,
# Docs: https://hexo.io/docs/one-command-deployment
# git@gitee.com:用户名/仓库名.git
deploy:
type: git
repo: git@github.com:Notes366/notes366.github.io.git
branch: master

#登录https://www.leancloud.cn/ 华东feng
# 添加白名单域名 https://notes366.github.io/ 可以评论