一、安裝新版本的nodejs和npm
安裝n模塊:
npm install -g n
升級(jí)node.js到最新穩(wěn)定版
n stable
二、安裝hexo
note: 參考github,不要去其官網(wǎng)
安裝Hexo
npm install hexo-cli -g
Setup your blog
hexo init blemeshcd blemesh
安裝Cactus主題,眾多開源主題中比較簡潔的一個(gè):
主題頁
Cactus頁
git clone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus
修改主題配置:
vim _config.yml
# Extensions## Plugins: https://hexo.io/plugins/## Themes: https://hexo.io/themes/## theme: landscapetheme: cactustheme_config:colorscheme: white
Create pages and articles with the hexo new [layout] <title> command. For example, to create an "about me" page, run:
hexo new page about
This will create a new file in source/about/index.md Similary, you can create a new article with
hexo new post "hello world"
and add some interesting content in source/_posts/hello-world.md.
Start the server:
hexo server
8001 port:
hexo server -p 8001
三、安裝hexo-admin并配置
安裝:
npm install --save hexo-admin
打開目錄下的_config.yml配置hexo-admin:
admin:
username: XXXX(自己設(shè)置用戶名)password_hash: XXXXXXXXX(密碼,但是是明文經(jīng)過bcrypt hash加密后生成的)secret: hey hexo(用于cookie安全)deployCommand: './admin_script/hexo-generate.sh'(調(diào)用該腳本)
注:
1)其中password_hash是你自己的明文密碼經(jīng)過加密后的字符串,但是如果用類似下面的網(wǎng)址: https://bcrypt-generator.com/ 會(huì)生成:$2y$10$pJjIxxxxxfMn9U/xxxxxNuuA20kh1eoB7vZxxxxx/7WpeV7IOxxxx類似的加密串,但是運(yùn)行會(huì)報(bào)invalid salt revision錯(cuò)誤,其原因是:
➜ blemesh cat node_modules/hexo-admin/www/bundle.js | head -4851 | tail -10if (salt.charAt(0) != '$' || salt.charAt(1) != '2')throw "Invalid salt version";if (salt.charAt(2) == '$')off = 3;else {minor = salt.charAt(2);if (minor != 'a' || salt.charAt(3) != '$')throw "Invalid salt revision";off = 4;}需要版本號(hào)是2a的加密方式,因此只能用python自己寫了:
https://pypi.org/project/bcrypt/3.1.0/
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(prefix=b"2a"))>>> print(hashed)b'$2a$12$PAoJr3USOBxxxxxxxxxxxxxxV/.h.QNbh/6q.xxxxxxxxxxxxxxxxcDcJ.'
2)其中配置中有個(gè)腳本: ./admin_script/hexo-generate.sh 需要自己創(chuàng)建:
➜ blemesh cat admin_script/hexo-generate.sh hexo g➜ blemesh chmod +x admin_script/hexo-generate.sh
新聞熱點(diǎn)
疑難解答
圖片精選