之前使用用git部署到github.io,但是github.io太慢了,只得上传到自己的云服务器。

配置

运行

1
$ npm install hexo-deployer-git --save

在自己的电脑上安装rsync(windows安装cwRsync,然后加进系统的PATH环境变量,执行cwrsync.cmd)将本机ssh密钥传到vps主机上,接着在vps上运行

1
$ cat id_rsa.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys

在hexo根目录下的 _config.yml 中加入

1
2
3
4
5
6
7
8
9
10
deploy:
type: rsync
host: <host> # 主机ip
user: <user> # 之前设置ssh的用户名
root: <root> # 远程主机文件存储位置
port: [port] # ssh登陆端口,一般填写22
delete: [true|false] # 是否删除远端存在而本地不存在的文件
args: --chmod=Dugo+r,Dugo+x,Du+w,Fugo+r,Fu+w # 提供的其它rsync参数信息
verbose: [true|false] # 输出详细信息,推荐true
ignore_errors: [true|false] # 即使出现IO错误也进行删除,推荐false

部署

1
$ hexo d