Hexo使用Rsync插件部署到远程Nginx服务器

本篇文章主要介绍了如何使用hexo提供的rsync插件,通过rsync把静态页面发布到远程nginx服务器

VPS上安装启动nginx

全部使用默认配置即可

1
2
3
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
service nginx start

VPS上添加rsync账户

1
2
3
4
5
6
# 添加账户
usradd hexo_rsync
# 设置账户密码
passwd hexo_rsync
# 添加nginx目录权限
chown -R hexo_rsync /usr/share/nginx/

本地把公钥发送到远程ssh服务器实现免密登录

  1. 安装ssh-copy-id
1
brew install ssh-copy-id
  1. 把本机公钥发送到远程服务器
1
ssh-copy-id -p {远程ssh端口} hexo_rsync@{远程ip}

本地Hexo使用Rsync插件

  1. 安装hexo-deployer-rsync插件
1
npm install hexo-deployer-rsync --save
  1. 修改_config.yml中deploy配置
1
2
3
4
5
6
7
8
9
deploy:
type: rsync
host: {远程ip}
user: hexo_rsync
root: /usr/share/nginx/html
port: {远程ssh端口}
delete: true
verbose: true
ignore_errors: false
  1. 执行生成以及发布
1
hexo g -d

Hexo使用Rsync插件部署到远程Nginx服务器

http://www.lephee.net/2018/01/08/hexo-rsync/

作者

LePhee

发布于

2018-01-08

更新于

2020-01-02

许可协议

评论