准备条件
- 一个域名:DNS解析到你的对应的服务器IP
- 服务器:
- 系统:centos-7.9.2009 [x86_64]
- CPU:Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz 2 Virtual Core
- 硬盘:22.61G
- 内存:1.79G
- Windows:
- 处理器:11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz 2.69 GHz
- 机带RAM:16.0 GB (15.7 GB 可用)
- 系统类型:64 位操作系统, 基于 x64 的处理器
- 笔和触控:没有可用于此显示器的笔或触控输入
服务端配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| yum -y update
yum install -y git nginx
mkdir -p /data/www/hexo chown -R $USER:$USER /data/www/hexo chmod -R 755 /data/www/hexo
vim /data/www/hexo/index.html
<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> </head> <body> <p>Nginx running</p> </body> </html>
vim /etc/nginx/nginx.conf
...... server { listen 80 default_server; listen [::]:80 default_server; server_name www.blog.com; root /data/www/hexo; } ......
mkdir -p /data/GitLibrary chown -R $USER:$USER /data/GitLibrary chmod -R 755 /data/GitLibrary
cd /data/GitLibrary git init --bare hexo.git
vim /data/GitLibrary/hexo.git/hooks/post-receive
git --work-tree=/data/www/hexo --git-dir=/data/GitLibrary/hexo.git checkout -f
chmod +x /data/GitLibrary/hexo.git/hooks/post-receive
|
本地计算机配置
Hexo官网要求:
Requirements
Installing Hexo is quite easy and only requires the following
beforehand:
- Node.js (Should be at least Node.js
10.13, recommends 12.0 or higher)
- Git
If your computer already has these, congratulations! You can skip to
the Hexo installation
step.
If not, please follow the following instructions to install all the
requirements.
Git安装
前往官网,选择对应系统安装包进行安装,终端输入
安装Node.js
前往官网,选择对应系统安装包进行安装,终端输入
1 2 3 4 5 6 7 8 9
| node -v npm -v
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm -v
cnpm config set registry https://registry.npm.taobao.org
|
安装Hexo及其插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| npm install hexo-cli hexo-server hexo-deployer-git -g
hexo init ~/Hexoblog
--------------------------------
url: http://www.blog.com //修改为你的个人博客域名 ......
deploy: type: git repo: [email protected]:/data/GitLibrary/hexo //用户名@域名或服务器IP:/data/GitLibrary/hexo(服务器git仓库路径) branch: master --------------------------------
|
开始部署
将本地博客部署至云服务器
1 2 3 4 5 6 7 8
| hexo clean
hexo g
hexo d
npm install hexo-deployer-git --save
|
部署完成之后,就可以通过配置号的域名访问你的博客(域名已经解析到对应的IP)