一、docker安装hexo
1.1 先是折腾docker
version: '3'
services:
hexo:
container_name: hexo
image: bloodstar/hexo:latest
hostname: hexo
ports:
- "7800:4000"
volumes:
- /volume1/docker/hexo/blog:/app
env_file:
- .env # 部分公用环境变量放到这里,以使得多个docker之间共享环境变量
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
- GIT_USER=User
- GIT_EMAIL=example@mail.com
# 主要为了内部npm网络访问顺利
- HTTP_PROXY=http://192.168.1.1:10000
- HTTPS_PROXY=http://192.168.1.1:10000
restart: always
# Copy this file to .env before building the container.
# Put any local modifications here.
PUID=1000
PGID=1000
TZ="Asia/Shanghai"
# USERDIR="/share/Container"
1.2 安装hexo后台
#!/bin/bash
echo "add User CMD here!"
echo "=====User CMD Start!====="
# 快速添加登录github秘钥
alias github='eval "$(/usr/bin/ssh-agent -s)";/usr/bin/ssh-add ~/.ssh/id_rsa'
# 重启内部pm2 服务器
alias repm2='pm2 restart /hexo_run.js'
#### debian 中国区加速
# 如果网络速度快,可以注释
sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
#### npm 配置
npm config ls -l
mkdir -p /app/.cache/npm
npm config set cache "/app/.cache/npm"
# npm config set userconfig "/app/.npmrc"
# npm config set registry https://registry.npmmirror.com
npm config set registry https://registry.npmjs.org/
#### history 持久化
rm -rfv ~/.bash_history
ln -s /app/.bash_history ~/.bash_history
#### ssh 配置
#### 避免 "Are you sure you want to continue connecting (yes/no)? yes"
chmod 600 /app/.ssh/id_rsa
chmod 644 /app/.ssh/id_rsa.pub
chmod 700 /app/.ssh
rm -rfv ~/.ssh
ln -s /app/.ssh ~/.ssh
#### npm 插件安装
# 这里用户可以修改自定义安装
npm install --save \
hexo-admin \
hexo-include-markdown \
hexo-douban-card-new \
hexo-github-card \
hexo-bilibili-card-new \
hexo-feed
echo "=====User CMD end!====="
1.3 安装主题
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
npm i hexo-theme-butterfly
1.4 配置主题
设置主题在hexo根目录/bolg的config file _config.yml:
theme: butterfly
If you don’t have pug & stylus renderer, try this:
npm install hexo-renderer-pug hexo-renderer-stylus
[Butterfly] (https://github.com/jerryc127/hexo-theme-butterfly)
1.5 使用hexo
● hexo n "我的第一篇文章" 等价于 hexo new "我的第一篇文章" 还等价于 hexo new post "我的第一篇文章"
● hexo p 等价于 hexo publish
● hexo g 等价于 hexo generate
● hexo d 等价于 hexo deploy
● hexo g -d等价于hexo generate --deploy
● hexo clean 没有 简写, git --version 没有简写
致谢:
评论交流
欢迎留下你的想法