服务器上部署HEXO博客
前言
如果觉得Blog托管服务满足不了自己折腾,可将资源迁移到自己的云服务器上
目标
- 服务端部署hexo博客站点环境
- 客户端发布文章推送到服务端
准备环境
服务端必备软件
- Git
- Nginx
客户端必备软件
- Git
- Node.js
- hexo
服务端配置(以Centos为例)
添加Epel源方便yum安装Nginx
1 |
|
安装Git Nginx
1 |
|
创建Nginx用户与群组
1 |
|
创建Nginx hexo站点文件目录
1 |
|
配置Nginx
配置文件路径
1 |
|
所需修改段
1 |
|
执行service nginx configtest检查nginx.conf语法是否正确,显示success
然后重启service nginx restart
Git 配置
创建文件目录,用于私人Git仓库搭建
1 |
|
Git 初始化裸库
1 |
|
创建Git钩子(hook)
1 |
|
指定Nginx站点目录与Git仓库地址
1 |
|
保存退出并添加执行权限
1 |
|
客户端配置
本篇以本地虚拟机Centos为例,其它平台对应搜索方知如何安装。
安装Git Nodejs
1 |
|
安装hexo
1 |
|
hexo初始化与安装
1 |
|
至于后面的hexo详细配置,请参照hexo 文档.
配置本地客户端与服务端连接
打开站点配置文件
1 |
|
设置Deployment字段
1 |
|
如果每次发布都要输入密码嫌麻烦,可以配置客户端与服务端RSA认证,如果不知可以通过搜索引擎找到。
配置Git邮箱与用户
Git初次连接需要配置邮箱与用户
1 |
|
部署hexo
将本地生成的静态文件部署到服务端
清除缓存
1 |
|
生成静态页面
1 |
|
启动服务器
1 |
|
将本地hexo目录文件部署到服务端
但是在这之前需要安装hexo-deployer-git
插件
1 |
|
然后执行部署
1 |
|
结语
看似写了一大推,其实也没多少地方要配置的,Blog部署起来反而简单了。
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!