1.安裝Node.js-4.4.4
這里4.4.4是目前的穩(wěn)定版,你可以去官網(wǎng)下載最新的穩(wěn)定版下載
- 下載
wget https://nodejs.org/dist/v4.4.4/node-v4.4.4-linux-x64.tar.xz
另可參考:https://linux.cn/article-5766-1.html
- 解壓
xz -d node-v4.4.4-linux-x64.tar.xz tar -xvf node-v4.4.4-linux-x64.tar
- 安裝
mv node-v4.4.4-linux-x64 node-v4.4.4
mv node-v4.4.4 /usr/local/node
- 配置環(huán)境變量
# 編輯 /etc/profile (使用vim)
vim /etc/profile
# 在底部添加 PATH 變量
export PATH=$PATH:/usr/local/node/bin
# 保存退出昧捷,先按exit鍵褐健,再按shift+:
wq
# 最后保存阳懂,使其生效即可
source /etc/profile
驗(yàn)證馏慨,命令行輸入npm -version
,安裝成功會(huì)輸出版本號(hào)
2.安裝Hexo
安裝這個(gè)可以不使用root用戶(hù)音婶,但是全局安裝時(shí)需要管理員權(quán)限哥蔚,現(xiàn)在目錄依舊是/home/Zing下倒谷,用戶(hù)是Zing
- 安裝Git(已安裝可跳過(guò))
apt-get install git
- 安裝hexo
# 創(chuàng)建目錄
mkdir hexo
# 切換目錄
cd hexo
# 全局安裝 Hexo,需要最高權(quán)限糙箍,記得輸入root密碼
sudo npm install -g hexo-cli
# 初始化 Hexo
hexo init
- 安裝插件
npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
npm install hexo-server --save
npm install hexo-deployer-git --save
npm install hexo-deployer-heroku --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-openshift --save
npm install hexo-renderer-marked --save
npm install hexo-renderer-stylus --save
npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save
- 測(cè)試安裝成功
hexo server
成成功會(huì)有下圖提示:
成功渤愁!
沒(méi)有提示,請(qǐng)重新安裝
瀏覽器輸入 http://0.0.0.0:4000 可以訪問(wèn)到首頁(yè)
效果
3.部署到github
這里的部署跟在CentOS上一樣深夯,如果是第一次抖格,分下面幾個(gè)步驟
可參照我前一篇文章
CentOS下搭建Hexo + github 博客
- 初始化Git設(shè)置(設(shè)置用戶(hù)名和郵箱)
- 生成SSH秘鑰將,SSH秘鑰配置到github上
- 在github上創(chuàng)建
用戶(hù)名.github.io
的倉(cāng)庫(kù)咕晋。并且編輯Hexo的_config.yml文件雹拄,配置好git提交倉(cāng)庫(kù)地址 - 編譯Hexo的MarkDown 文章,部署到github上
用戶(hù)名一定是你github上的用戶(hù)名掌呜!切記滓玖!
4.選擇主題
- 4.1安裝主題NexT
ps:我們現(xiàn)在在目錄hexo下
git clone https://github.com/iissnan/hexo-theme-next themes/next
并在目錄hexo下的_config.yml中
# 找到 theme: 修改后面的參數(shù),默認(rèn)是 landscape
theme: next
4.2配置主題源碼拷貝出來(lái)太多了质蕉,所以貼出next的使用說(shuō)明供大家參考
4.3找主題https://hexo.io/themes/