基于VuePress搭建知识库

我这边需要搭建一个运维知识库,将项目的方方面面记录下来,方便新手接手运维。

准备环境

  • Nginx 1.19.0
  • VuePress 1.x
  • Minio RELEASE.2022-02-16T00-35-27Z
  • vuepress-theme-vdoing主题

安装VuePress

根据官网步骤即可

复制代码
# 创建目录
mkdir vuepress-starter && cd vuepress-starter

# 初始化
npm init

# 安装VuePress
npm install -D vuepress

# 创建文档 注意这里可能会有问题,需要把文件格式改成UTF-8
mkdir docs && echo '# Hello VuePress' > docs/README.md

# package.json加入脚本
{
  "scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }
}

上述即可正式启动一个VuePress

我这边用了vuepress-theme-vdoing主题,也需要安装一下

复制代码
npm install vuepress-theme-vdoing -D

然后在.vuepress/config.js指定主题

复制代码
module.exports = {
  theme: 'vdoing'
}

这边的config.js目前是以下配置

复制代码
module.exports = {
  title: '知识库',
  description: '运维人员知识分享',
  theme: 'vdoing',
  base:'/knowledge/',
  themeConfig: {
    # 导航条
    nav:[
       {text:"首页",link:"/"},
       {text:"第三方平台",link:"/third/"},
       {text:"数据",link:"/data/"},
       {text:"小知识",link:"/technology/"}
    ],
    sidebar: 'structuring'
 }
}

填充内容

修改首页docs\README.md

复制代码
---
home: true
# heroImage: /img/web.png
heroText: 运维知识库
tagline: 记运维过程中的各种知识,帮助每一个过来运维的负责人更快的投入到工作。
# actionText: 立刻进入 →
# actionLink: /web/
# bannerBg: auto # auto => 网格纹背景(有bodyBgImg时无背景),默认 | none => 无 | '大图地址' | background: 自定义背景样式       提示:如发现文本颜色不适应你的背景时可以到palette.styl修改$bannerTextColor变量

features: # 可选的
  - title: 第三方平台
    details: 非本公司平台操作内容
    link: /third/
    imgUrl: /img/ui.png
  - title: 数据
    details: 数据等内容
    link: /data/
    imgUrl: /img/python.png
  - title: 小知识
    details: 技术文档、教程、技巧、总结等文章
    link: /technology/
    imgUrl: /img/other.png

完成首页即可,可以在docs文件夹下写文章内容。

部署

打包

复制代码
vuepress build docs

打包完成生成的静态文件会在.vuepress\dist下面。

即可通过nginx部署,这边我是挂在公司的平台下的

复制代码
location  /knowledge {
    alias /data/knowledge/dist;
    index  index.html index.htm;
    try_files $uri $uri/ /data/knowledge/dist/index.html;
}

知识库需要用到图片服务器,所以这里也用到了minio,minio操作方式特别简单,这里不多介绍。

复制代码
location /public-doc/ {
    proxy_pass http://ip:9000/public-doc/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;
    proxy_connect_timeout 60s;
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Methods' 'GET,PUT,POST,DELETE,OPTIONS';
    add_header 'Access-Control-Allow-Header' 'Content-Type,*';
}

在这里我是代理了minio的图片服务,需要注意在vuepress中使用存在跨域问题,所以这里需要这样配置。

经过一天的安装配置,正式搭建完成,整个流程比较简单,多看看官网即可解决。之后就是补充内容,完善运维文档。

相关推荐
甲鱼92916 小时前
MySQL 实战手记:日志管理与主从复制搭建全指南
运维
碳基沙盒3 天前
OpenClaw 多 Agent 配置实战指南
运维
蝎子莱莱爱打怪6 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
DianSan_ERP6 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
呉師傅6 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
不是二师兄的八戒6 天前
Linux服务器挂载OSS存储的完整实践指南
linux·运维·服务器
zhangfeng11337 天前
趋动云 如何ssh登录 服务区 项目server
运维·人工智能·ssh
ZeroNews内网穿透7 天前
谷歌封杀OpenClaw背后:本地部署或是出路
运维·服务器·数据库·安全
失重外太空啦7 天前
nginx
运维·nginx
Gofarlic_oms17 天前
避免Kisssoft高级分析模块过度采购的科学评估方法
大数据·linux·运维·人工智能·matlab