★☆ CentOS搭建nginx环境get上传hexo网页
正文
github提供的静态博客功能很强大
但是总有些py交易不能放在github上
那就在第三方服务器搭建nginx,get环境
最后hexo本地编辑网页
最后上传
完工
代码1-CentOS
1 | //由于centos的yum仓库没有nginx 咱们先安装EPEL |
代码2-本地
//本地安装 git hode.js
//git中安装hexo
$npm install -g hexo
$npm install
#设置博客根目录
$hexo init
/*
//这些可以不用配
//配置ssh
ssh-keygen -t rsa -C "***@qq.com"
//找到公钥
#C:\Users\Administrator\.ssh
*************
//服务器添加
cd /data/git
mkdir .ssh
nano /data/git/.ssh/authorized_keys
*/
//这个总知道吧
deploy:
type: git
repo: root@*.*.*.*:/data/git/hexo.git
branch: master
//如果 hexo d 报错的话 可以安装这个
npm install --save hexo-deployer-git
代码3-CentOS
/*
//这一段新手就不要改了直接用nginx的默认目录
//配置nginx
vi /etc/nginx/nginx.conf
#更改 root 为/data/git/www 更改location/为 index index.html index.htm;
/bin/systemctl restart nginx.service
*/
//建立钩子
mv post-update.sample post-update
//写入post-update
git --work-tree=/data/git/www --git-dir=/data/git/hexo.git checkout -f
//建立钩子(使用默认nginx路径的话)
mv post-update.sample post-update
//写入post-update
git --work-tree=/usr/share/nginx/html --git-dir=/data/git/hexo.git checkout -f
chmod +x post-update