最近打算在自己的服务器上上个blog功能,github上找到了Docusaurus
这个号称属于程序员的blog神器,三分钟搭建完成,该博客适用于使用markdown
使用者~
实际操作起来有很多的坑,最为明显的是nodejs的安装配置,如果你是老电脑,nodejs版本会很低,甚至于根本没装
nodejs版本需求
[Node.js](https://nodejs.org/en/download/) version >= 8.10.0
一、yarn的安装以及node的安装(!墙裂!不建议手动安装node,不熟悉nodejs的会引出很多的问题)
yarn 安装教程
使用yarn安装node
yarn add node
mac电脑可使用homebrew安装node
brew install node
安装完成后node -v
查看安装版本,不得低于8.10.0
二、Docusaurus的简单使用
进入要安装的目录下cd 你准备的文件夹目录
,然后运行一下命令 以classic
创建一个样例模板
npx @docusaurus/init@next init binBlog classic
执行成功后命令行日志输入
Success! Created binBlog
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm deploy
Publish website to GitHub pages.
We suggest that you begin by typing:
cd binBlog
npm start
完成后运行一下命令
cd my-website
npm run start
服务成功启动,浏览器打开http://localhost:3000/
即可预览
✔ Client
Compiled successfully in 8.08s
ℹ 「wds」: Project is running at http://localhost:3000/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/mac/Desktop/Docusaurus/binBlog
ℹ 「wds」: 404s will fallback to /index.html
✔ Client
Compiled successfully in 77.98ms

三、Docusaurus的发布
先来看下工程的目录结构

与之对应的站点

构建项目并发布到服务器
1.使用tomcat
提供web服务器功能
java环境的安装以及tomcat安装
2.构建项目,并提交的tomcat
中
在binBlog文件夹下执行构建命令
npm run build

3、文件夹改名(!!改成ROOT,tomcat默认打开的是ROOT工程),然后上传至
tomcat的webapps目录下
比如:(目录因系统而异,仅供参考)
/var/lib/tomcat/webapps
tomcat默认开启的是8080端口
http://你服务器的ip地址/域名:8080/
网友评论