环境准备CentOS7.9
安装nodejs
curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash -
yum install -y nodejs
To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
安装git
sudo yum install git-core -y
安装hexo
npm install hexo-cli -g
安装时间略长。
[root@lab4 ~]# npm install hexo-cli -g
/usr/bin/hexo -> /usr/lib/node_modules/hexo-cli/bin/hexo
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ hexo-cli@4.2.0
added 65 packages from 339 contributors in 305.415s
Linux users can set relative path of node_modules/ folder:
echo ‘PATH="$PATH:./node_modules/.bin"’ >> ~/.profile
then check Hexo using:
[root@lab4 ~]# hexo --version
hexo-cli: 4.2.0
os: Linux 3.10.0-1160.el7.x86_64 linux x64
node: 14.16.0
v8: 8.4.371.19-node.18
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.16.1
modules: 83
nghttp2: 1.41.0
napi: 7
llhttp: 2.1.3
openssl: 1.1.1j
cldr: 37.0
icu: 67.1
tz: 2020a
unicode: 13.0
配置hexo
hexo init folder
cd folder
npm install
例如:
hexo init airport
cd airport
npm install
[root@lab4 node_modules]# hexo init airport
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO Install dependencies
added 190 packages from 445 contributors and audited 196 packages in 46.343s
15 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
INFO Start blogging with Hexo!
[root@lab4 node_modules]# cd airport
[root@lab4 airport]# ll
total 80
-rw-r--r--. 1 root root 0 Mar 7 23:27 _config.landscape.yml
-rw-r--r--. 1 root root 2441 Mar 7 23:27 _config.yml
drwxr-xr-x. 165 root root 8192 Mar 7 23:28 node_modules
-rw-r--r--. 1 root root 615 Mar 7 23:27 package.json
-rw-r--r--. 1 root root 57352 Mar 7 23:28 package-lock.json
drwxr-xr-x. 2 root root 52 Mar 7 23:27 scaffolds
drwxr-xr-x. 3 root root 20 Mar 7 23:27 source
drwxr-xr-x. 2 root root 22 Mar 7 23:27 themes
[root@lab4 airport]# npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 5 packages from 1 contributor and audited 196 packages in 3.131s
15 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
修改_config.yml文件中的url:
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: http://192.168.44.134:4000
装一个新主题: https://github.com/twoyao/beautiful-hexo
npm install --save hexo-generator-archive hexo-renderer-jade hexo-generator-tag hexo-generator-feed hexo-generator-sitemap hexo-browsersync
git clone --depth 1 https://github.com/twoyao/beautiful-hexo.git themes/beautiful-hexo
Modify _config.yml change theme to beautiful-hexo and configure hexo-generator-archive :
theme: beautiful-hexo
archive_generator:
per_page: 0
yearly: false
monthly: false
daily: false
创建一个文档:
hexo new “My First Doc”
hexo new page --path about/me “About me”
hexo generate
启动hexo服务器
hexo server
打开防火墙端口
firewall-cmd --permanent --add-port=4000/tcp
firewall-cmd --reload
[root@lab4 airport]# firewall-cmd --permanent --add-port=4000/tcp
success
[root@lab4 airport]# firewall-cmd --reload
success
浏览器访问
真他妈丑。快拉倒吧。
用浏览器访问:http://serverIP:4000/