美文网首页
Centos 6 x86 minimal搭建Hexo

Centos 6 x86 minimal搭建Hexo

作者: 禾白小三飘 | 来源:发表于2015-12-11 10:43 被阅读477次

记录一下我在Centos6.5mini下面搭建Hexo的过程。

安装环境

  1. 注册gitcafe,并新建一个与用户名相同的库。(参考此处)
  • 用户名:muc
  • 项目姓名:muc
  • 项目主页:http://muc.gitcafe.com
  1. 安装Node.js(参考此处)
  • curl -sL https://rpm.nodesource.com/setup | bash -
  • yum install -y nodejs
  1. 安装git
  • yum install git
  1. 安装Hexo(参考此处)
npm install -g hexo-cli
hexo init <folder>
cd <folder>
npm install

配置Hexo

vi _config.yml

  • 编辑_config.yml文件
# Site
title: "MUCH'S NOTES"
subtitle:
description:
author: Mu
language: zh-ch
timezone: Asia/Chongqing

最后一段的配置:

deploy:
  type: git
  repo: git@gitcafe.com:muc/muc.git
  branch: gitcafe-pages

保存退出(注意每个冒号后面需要跟空格。)

  • 再安装下面这个:
npm install hexo-deployer-git --save

git配置

  • 查看git配置git config -- list
  • 添加信息
git config --global user.name "muc"
git config --global user.email 114772883@qq.com
  • 添加SSH公钥
  1. 创建一个存放SSH的目录
    mkdir ~/.ssh
  2. 生成新的SSH公钥:
    ssh-keygen -t rsa -C "114772883@qq.com" -f ~/.ssh/gitcafe
  3. 生成配置文件
    vi ~/.ssh/config
    添加以下内容:
    Host gitcafe.com www.gitcafe.com
    IdentityFile ~/.ssh/gitcafe
  4. 进入GitCafe账户设置SSH公钥管理设置项,添加公钥
  • cd ~/.ssh
  • cat gitcafe.pub
  • 将查看到的内容复制,粘贴上去。
  1. 测试是否可以连接GitCafe服务器
  • ssh -T git@gitcafe.com -i ~/.ssh/gitcafe
  • 如果出现下面的提示就代表正确了:Hi muc! You've successfully authenticated, but GitCafe does not provide shell access.
  1. 最后Hexo的一些命令
  • 新建文章hexo new [layout] <title>
  • 生成网页hexo generate可简写为g
  • 部署网页hexo deploy可简写为d

同时使用nginx服务

gitcafe的生效时间比较长,每次我更新之后要等一段时间才能出现新内容。为此,再配置一个nginx能方便不少。

  • 安装nginx
  1. centos无法直接安装nginx,需要先安装EPEL参考此处。
    yum install epel-release
  2. 然后才能安装nginx
    yum install nginx
  • 配置nginx监听hexo
  1. vi /etc/nginx/conf.d/default.conf
  2. 为location配置,hexo的静态文件夹目录。
    location / {
        root  /var/hexo/public;
        index  index.html index.htm;
    }

相关文章

网友评论

      本文标题:Centos 6 x86 minimal搭建Hexo

      本文链接:https://www.haomeiwen.com/subject/koeyhttx.html