CentOS搭建hexo博客,实现自动化部署(一)

思路

将本机代码推送到github,然后服务器利用webhook,完成自动化部署。

本机安装git、hexo

安装git,请参考Windows7安装Git客户端
连接Github,请参考Window7下配置SSH连接GitHub

安装note.js

一路默认Next安装即可,下载note.js

node --version      #在cmd中输入命令,确认是否安装成功

安装hexo

npm install -g hexo-cli
hexo init blog   #路径为~/Desktop/git下
cd blog
npm install

hexo常用命令

hexo g # 生成
hexo s # 启动服务    #本地编辑用到hexo g和hexo s,打开http://localhost:4000/可在本地看到hexo系统
hexo clean  #清除缓存文件 (db.json) 和已生成的静态文件 (public)

hexo d命令使用

npm install hexo-deployer-git --save   #安装插件

修改git/blog/_config.yml配置,找到Deployment部分:

deploy:
  type: git
  repository: git@github.com:XXX/test.git     #github远程仓库的ssh url地址
  branch: master

后续可以愉快的使用hexo d将代码部署到github上

hexo d

下一篇实现服务器端配置

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容