hexo部署到阿里云

2022/7/25 6:52:58

本文主要是介绍hexo部署到阿里云,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  • 参阅: https://developer.aliyun.com/article/787380
  1. 创建git用户
useradd ugit
passwd  ugit
  1. 创建两个文件夹 repos(git仓库) 与 www(网页根目录)
cd /
mkdir m_www && cd m_www
  1. 创建网页仓库与网页根目
mkdir repos
mkdir www
  1. 递归更变用户组并赋予目录读写权限
chown -R ugit:ugit /m_www
chmod -R 755 /m_www
  1. 创建git钩子post-receive
    切换用户为ugit
su ugit
  1. 创建git仓库
git init --bare hexo.git

当git被存放到仓库时触发post-receive脚本并执行的脚本

sudo nvim /m_www/repos/hexo.git/hooks/post-receive

在post-receive脚本中添加以下代码, 制定Git的工作树与Git目录

#!/bin/bash
git --work-tree=/m_www/www/ --git-dir=/m_www/repos/hexo.git checkout -f

为脚本添加执行权限

sudo chmod +x post-receive
  1. 编辑nginx.conf 启动服务器
    打开nginx配置文件sudo nvim /etc/nginx/nginx.conf, 并http区块中添加以下内容, 如果配置包含sites目录[include /etc/nginx/sites-enabled/*], 那么请通过更变/etc/nginx/sites-enabled/default改变80端口所指向的目录。
server {
    listen       10001;
    server_name  localhost;
    location / {
        root   /var/m_www/Books;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   html;
}

重启nginx服务

systemctl restart nginx


这篇关于hexo部署到阿里云的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程