hexo+stellr+云服务器安装部署踩坑记录
1. 资源准备
1 | 云服务器: Centos7.9 |
2. 安装步骤
2.1 云服务器 相关安装
1 | ngnix: 1.22.1 |
2.1.1 git 安装
安装: root用户下执行:
1 | # 安装Git |
服务器ssh密钥设置: git用户下执行:
1 | # 切换到 git 用户,然后在~目录下创建.ssh文件夹 |
将本地电脑的id_rsa.pub文件的内容拷贝到云服务器的authorized_keys文件的末尾
在本地验证连接云服务器 ssh -v git@云服务器的公网IP
创建git仓库:git用户下执行:
1 | cd ~ |
此目录需要在git用户下可以访问到
2.1.2 ngnix 安装
所有操作使用root用户
yum安装失败后,改用编译安装成功
修改配置:
1 | cd /usr/local/ngnix/conf |
此目录需要在root用户下可以访问到,否则会403
2.1.3 安装node
我是使用的云服务器的宝塔界面安装的,手动安装方式自行查找
2.2 本地电脑部署
2.2.1 安装node
已有,自行查找
2.2.2 安装Hexo
1 | npm install hexo-cli -g |
2.2.3 设置Hexo部署云服务器
1 | npm install hexo-deployer-git --save |
执行过程报错:npm ERR! Cannot read properties of null (reading 'matches')
解决方案:This error shows up when you run npm install
in a directory where you previously ran pnpm install
. The solution is to remove your node_modules
directory and run npm install
again.
打开_config.yml文件,修改deploy项目如下
1 | deploy: |
生成站点文件并推送至远程库:
1 | hexo clean && hexo deploy |
2.3 Stellar主题设置
2.3.1 字体设置
我选用lxgw-wenkai字体
在_config.yml
中写入
1 | inject: |
并在 _config.stellar.yml
中填写你引入的字体名称
1 | style: |
2.3.2 评论插件设置
我采用giscus
在_config.stellar.yml中添加:
1 | comments: |
其中只需要获取 data-repo
data-repo-id
data-category
data-category-id
在giscus页面,按照此页面流程配置后会生成上面需要的信息
- 创建一个公开的github仓库,并在设置中将discussion启用
- giscus app 安装,否则访客将无法评论和回应。安装时选择刚刚创建的仓库
- 在giscus页面填写仓库
- 选择页面与嵌入的 discussion 之间的映射关系,默认**
pathname
**即可 - 选择新 discussions 所在的分类,选择推荐
announcements
即可
现在在giscus页面下方生成需要的信息了,将其填入_config.stellar.yml
填入时注意是yaml格式,不要简单的粘贴复制
3. 写作
3.1 文章
1 | cd /Users/zhaoyuzhe/VScodeProjects/hexo_yuzhe |