aliyun部署hexo
准备阶段
服务端工具
- 大前提是你有台服务器
- optional[域名]
- nodejs
- git
- nginx
服务端预处理阶段
- 换源(如果对原来的镜像速度不满意的话)
- 打开服务器端口(80,22)等
相关安装命令
1 | sudo apt update |
本地准备
- 配置本地hexo工作目录
1 | cd ${你想要的路径(比如 E:/hexo-blog)} |
搭建
添加用户git -> server
1
2adduser git
adduser git sudo切换git用户配置ssh -> server
1
2
3
4
5
6su git
mkdir ~/.ssh
ssh-keygen --> 一路enter到结束就行
cp ~/.ssh/id_rsa.pub authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh如果之前没生成ssh_key 则调用ssh-keygen 生成一份,并将本地的id_rsa.pub文件内容放到server的authorized_keys文件夹末尾(不能覆盖) -> 本地
1
2ssh-keygen ...
ssh -v git@server_ip -> 测试是否能访问创建空git项目并启用hooks ->
1
2
3
4
5
6--git用户
cd ~
git init --bare blogs.git
nvim ~/blogs.git/hooks/post-receive
通过nvim 添加以下内容至post-receive中
git --work-tree=${博客路径} --git-dir=/home/git/blog.git checkout -f个人建议直接放到/home/git/dirs 下,省了个文件夹授权操作.
1
chmod +x ~/blog.git/hooks/post-receive ->赋予可执行权限
配置nginx
1 | mkdir /etc/nginx/vhost |
1 | 在 /etc/nginx/nginx.conf文件中引入上述自定义配置文件 |
记得修改nginx 的默认访问文件
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.