安装hexo
软件 | 版本 |
---|
nodejs | 16.20.0 |
nginx | 1.24.0 |
节点 | IP | 系统 | 功能 | CPU | 内存 | 硬盘 |
---|
node1 | 10.80.10.1 | centos7.9 | hexo | 4核心 | 8GB | 20GB |
node1
下载安装nodejs:
下载地址:https://nodejs.org/dist/v16.20.0/
1 2 3 4
| # cd /usr/local/src/ # wget https://nodejs.org/dist/v16.20.0/node-v16.20.0-linux-x64.tar.gz # tar -xzvf node-v16.20.0-linux-x64.tar.gz # mv node-v16.20.0-linux-x64 /usr/local/node
|
添加环境变量:
1 2 3
| # vim /etc/profile # 尾行,添加node环境变量 PATH=$PATH:/usr/local/node/bin
|
1 2 3 4 5 6
| # source /etc/profile # node -v v16.20.0 # npm -v 8.19.4 15
|
下载安装git:
下载安装hexo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| # npm install -g hexo-cli # hexo version INFO Validating config hexo: 7.0.0 hexo-cli: 4.3.1 os: linux 3.10.0-1160.31.1.el7.x86_64 CentOS Linux 7 (Core) node: 16.20.0 v8: 9.4.146.26-node.26 uv: 1.43.0 zlib: 1.2.11 brotli: 1.0.9 ares: 1.19.0 modules: 93 nghttp2: 1.47.0 napi: 8 llhttp: 6.0.10 openssl: 1.1.1t+quic cldr: 41.0 icu: 71.1 tz: 2022f unicode: 14.0 ngtcp2: 0.8.1 nghttp3: 0.7.0
|
初始化hexo:
1 2 3 4
| # mkdir -p /data/hexo # cd /data/hexo/ # hexo init # hexo g
|
编写js脚本,后台启动hexo:
1 2 3 4 5 6 7 8 9 10 11 12
| # cd /data/hexo/ # npm install -g pm2 # vim /data/hexo/run.js const {exec} = require('child_process') exec('hexo server -p 80',(error, stdout, stderr) => { if(error){ console.log(`exec error: ${error}`) return } console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); })
|
1 2 3
| # pm2 start /data/hexo/run.js # netstat -tlunp | grep 4000 tcp6 0 0 :::4000 :::* LISTEN 49712/hexo
|
浏览器访问:http://10.80.10.1:4000/
重启hexo:
1
| # pm2 restart /data/hexo/run.js
|