其他分享
首页 > 其他分享> > hexo部署到阿里云

hexo部署到阿里云

作者:互联网

  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

标签:www,git,hexo,部署,nginx,阿里,ugit,post,receive
来源: https://www.cnblogs.com/jingpengblog/p/16516085.html