目录
前言
一、git安装
二、git配置
三、创建git仓库
四、配置本地Hexo,构建至服务器
五、部署
前言
将Hexo部署至服务器,记录部署过程
yum install git
git version
adduser git
chmod 740 /etc/sudoers
vim /etc/sudoers
i
键进入文件的编辑模式,按方向下键找到找到root下添加以下信息git ALL=(ALL) ALL
chmod 400 /etc/sudoers
sudo passwd git
su git
mkdir ~/.ssh
i
键进入文件的编辑模式,将密钥粘贴进去,再按 esc 键退出编辑模式,输入 :wq 回车 保存退出)vim ~/.ssh/authorized_keys
chmod 600 /home/git/.ssh/authorized_keys
chmod 700 /home/git/.ssh
ssh -v git@ip地址
su root
mkdir /home/hexo
chown git:git -R /home/hexo
cd /home/git
git init --bare blog.git
chown git:git -R blog.git
/home/hexo/blog.git
下,有一个自动生成的 hooks
文件夹,我们在该文件夹下新建一个新的钩子文件 post-receive ,用于自动部署vim blog.git/hooks/post-receive
i
键进入文件的编辑模式,添加下面两行代码,用于指定git执行目录 #!/bin/bash git --work-tree=/home/hexo --git-dir=/home/git/blog.git checkout -f
chmod +x /home/git/blog.git/hooks/post-receive
deploy:type: git#git@ip地址(或域名):/仓库地址repo: git@xxxx:/home/git/blog.git#分支branch: master
hexo clean
hexo g -d