本篇文章主要介绍了如何使用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
chown -R hexo_rsync /usr/share/nginx/
|
本地把公钥发送到远程ssh服务器实现免密登录
- 安装ssh-copy-id
1
| brew install ssh-copy-id
|
- 把本机公钥发送到远程服务器
1
| ssh-copy-id -p {远程ssh端口} hexo_rsync@{远程ip}
|
本地Hexo使用Rsync插件
- 安装
hexo-deployer-rsync
插件
1
| npm install hexo-deployer-rsync --save
|
- 修改
_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
|
- 执行生成以及发布