记录一下我在Centos6.5mini下面搭建Hexo的过程。
安装环境
- 用户名:
muc
- 项目姓名:
muc
- 项目主页:
http://muc.gitcafe.com
- 安装Node.js(参考此处)
curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs
- 安装git
yum install git
- 安装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公钥
- 创建一个存放SSH的目录
mkdir ~/.ssh
- 生成新的SSH公钥:
ssh-keygen -t rsa -C "114772883@qq.com" -f ~/.ssh/gitcafe
- 生成配置文件
vi ~/.ssh/config
添加以下内容:
Host gitcafe.com www.gitcafe.com
IdentityFile ~/.ssh/gitcafe
- 进入
GitCafe
→账户设置
→SSH公钥管理
设置项,添加公钥
cd ~/.ssh
cat gitcafe.pub
- 将查看到的内容复制,粘贴上去。
- 测试是否可以连接GitCafe服务器
ssh -T git@gitcafe.com -i ~/.ssh/gitcafe
- 如果出现下面的提示就代表正确了:Hi muc! You've successfully authenticated, but GitCafe does not provide shell access.
- 最后Hexo的一些命令
- 新建文章
hexo new [layout] <title>
- 生成网页
hexo generate
可简写为g - 部署网页
hexo deploy
可简写为d
同时使用nginx服务
gitcafe的生效时间比较长,每次我更新之后要等一段时间才能出现新内容。为此,再配置一个nginx能方便不少。
- 安装nginx
- centos无法直接安装nginx,需要先安装EPEL参考此处。
yum install epel-release
- 然后才能安装nginx
yum install nginx
- 配置nginx监听hexo
vi /etc/nginx/conf.d/default.conf
- 为location配置,hexo的静态文件夹目录。
location / {
root /var/hexo/public;
index index.html index.htm;
}
网友评论