このブログはHexoというブログエンジン(静的ページのジェネレーター)で立ち上げました
そのときのHexoでブログを立ち上げてwebブラウザから管理できるように導入するメモです
hexoのインストール
https://hexo.io/1
2
3
4npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo-adminのインストール
管理画面のプラグインを追加
hexo-admin1
npm install --save hexo-admin
設定ファイル(blog/_config.yml)にログイン情報を追加(追加しない場合ログインなしで管理画面に入れる)1
2
3
4admin:
username: tsuno
password_hash: $2a$10$8f0CO288aEgpb0BQk0mAEOIDwPS.s6nl703xL6PLTVzM.758x8xsi
secret: a secret something
パスワードは以下のようにしてハッシュ化して入れる1
2
3
4$ node
> const bcrypt = require('bcrypt-nodejs')
> bcrypt.hashSync('your password here !')
//=> '$2a$10$8f0CO288aEgpb0BQk0mAEOIDwPS.s6nl703xL6PLTVzM.758x8xsi'
起動
1 | hexo server -p 3000 -d |
- -p : ポート指定
- -d : hexo-adminのオプション
デーモン化
ページを作成するときにいちいちHexoを起動するのも面倒なので、systemdでデーモン化します
/etc/systemd/system/blog.serviceを以下の内容で追加1
2
3
4
5
6
7
8
9
10
11
12[Service]
WorkingDirectory=/home/tsuno/blog
ExecStart=/bin/hexo server -p 3000 -d
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=hexo
User=tsuno
Group=tsuno
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
1 | systemctl daemon-reload |
最後に
簡単に導入できました
でも管理画面が若干ダサいのでどうしよう