centos7安装hexo

1 首先先安装 Node.js 和 Git

如果您的电脑中已经安装上述必备程序,那么恭喜您!你可以直接安装 Hexo步骤。

如果您的电脑中尚未安装所需要的程序,请根据以下安装指示完成安装。

安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

2 使用 npm 安装 Hexo。

[root@lizhw local]# npm install -g hexo-cli
#创建用户 -m选项表示生成用户主目录
[root@lizhw hexo]# useradd -m lizhw
[root@lizhw hexo]# passwd lizhw
#切换用户
[root@lizhw hexo]#  su wenli
[root@lizhw hexo]#  cd ~
#初始化Hexo
[root@lizhw hexo]# hexo init blog
#生成静态文件
[root@lizhw hexo]# cd blog
[root@lizhw hexo]# hexo generate
#开启本地服务器
[root@lizhw hexo]# hexo s

3.安装nginx

[root@lizhw hexo]# yum install nginx -y
[root@lizhw hexo]# vim /etc/nginx/nginx.conf
#修改配置
server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /home/lizhw/codes/blog/public;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }
 #启动nginx
[root@lizhw hexo]#systemctl start nginx.service

5 验证成功:

访问 http://39.102.73.26/

6 创建博客

#在blog根目录下
[root@lizhw blog]# hexo new '我的第一篇文章'
[root@lizhw blog]# cd /source/_posts/
[root@lizhw _posts]# vi '我的第一篇文章'
[root@lizhw _posts]# cd ../../
[root@lizhw blog]# hexo clean
[root@lizhw blog]# hexo g
[root@lizhw blog]# hexo s

7 更换主题(Butterfly)

在博客根目录下

[root@lizhw blog]# git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
# 升级 git pull

应用主题

# 修改根目录下:_config.yml
theme: butterfly

如果报错

extends includes/layout.pug block content include ./includes/mixins/post-ui.pug #recent-posts.recent-posts +postUI include includes/pagination.pug

说明你沒有 pug 以及 stylus 的渲染器,执行下面命令安装:

[root@lizhw blog]# npm install hexo-renderer-pug hexo-renderer-stylus --save

最后依次执行:

hexo clean 、 hexo g 、 hexo s

centos7安装node.js

1 下载安装包3

可以在https://nodejs.org/en/download/下载

2 上传至服务器3

个人习惯把安装包放在/usr/local下

[root@lizhw soft]# pwd
/usr/local/soft
[root@lizhw soft]# ll
total 14360
-rw-r--r-- 1 root root 14700900 Sep  1 13:26 node-v12.18.3-linux-x64.tar.xz
[root@lizhw soft]# 

3 解压包并进入目录配置

[root@lizhw soft]# tar -xvf node-v12.18.3-linux-x64.tar.xz
[root@lizhw soft]# cd node-v12.18.3-linux-x64

# 安装gcc gcc-c++ 环境
[root@lizhw soft]# sudo yum install gcc gcc-c++

# 建立软件连接
[root@lizhw bin]# ln -s /usr/local/soft/node-v12.18.3-linux-x64/bin/npm  /usr/local/bin/
[root@lizhw bin]# ln -s /usr/local/soft/node-v12.18.3-linux-x64/bin/node  /usr/local/bin/

# 配置 profile 文件
[root@lizhw bin]# vi /etc/profile
export NODE_HOME=/usr/local/soft/node-v12.18.3-linux-x64
export PATH=$PATH:$NODE_HOME/bin:$PATH
[root@lizhw bin]# source /etc/profile

4 验证是否安装成功

[root@lizhw local]# node -v
v12.18.3

centos7安装 git

1 直接yum安装最新版本

[root@lizhw local]# yum install -y git

2 验证是否安装成功

[root@lizhw local]# git version
git version 1.8.3.1
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值