3
如何在服务器上部署一个基于 Node.js 的 TiddlyWiki
source link: https://imzm.im/how-to-host-a-nodejs-version-tiddlywiki/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
pimgeek 的数字花园即为此模式,现记录部署过程。什么是 TiddlyWiki?
前置条件是要有一个域名和一个 VPS。
安装 Node.js 和 TiddlyWiki
- 更新软件包
apt update
- RedHat 系使用
yum
- RedHat 系使用
- 安装 Node.js
apt install npm
- 全局安装 TiddlyWiki
npm install -g tiddlywiki
- 检查 TiddlyWiki 版本
tiddlywiki --version
- 创建 TiddlyWiki 目录
mkdir ~/wiki
wiki 可以替换为想要的名字 - 在 TiddlyWiki 目录下创建基本文件
tiddlywiki wiki --init server
- 创建用户权限文本
vim ~/wiki/users.csv
或者用 nano 等文本工具
users.csv
文本内容:
username,password
johndoe,!@#$%^
其中首行为必填项,第二行为用户名和明文密码,英文小写逗号,不包含任何空格(具体参考官方文档:WebServer Parameter: credentials)
安装 Nginx 和 Let's Encrypt
熟悉的话这一步可以略过。重点是设置好反向代理。
- 安装 Nginx
apt install nginx
- 创建并编辑代理服务器配置
cd /etc/nginx/sites-available
然后vim example.com
- 其中 example.com 为域名
example.com
文本内容:
server {
server_name example.com
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
其中 client_max_body_size
条目设置最大上传文件大小
- 链接并启用代理服务器
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled
- 安装 Let's Encrypt 以及激活 nginx 插件
apt install certbot python3-certbot-nginx
- 创建 SSL 认证
certbot --nginx
按照说明进行设置 - 运行 TiddlyWiki 并访问域名测试是否启动成功
tiddlywiki wiki --listen credentials=users.csv "readers=(anon)" "writers=(authenticated)"
- 其中
creadentials
字段指定用户权限文本名称,readers
为只读权限(此处的anon
为匿名,即任意访客),writers
为读写权限(authenticated
读取credentials
中指定的用户)
安装 pm2 并设置后台运行服务
- 全局安装最新版本 pm2
npm install -g pm2@latest
- 准备 TiddlyWiki 启动脚本
vim ~/tw.sh
脚本内容:
cd /root
tiddlywiki wiki --listen credentials=users.csv "readers=(anon)" "writers=(authenticated)"
- 赋予
tw.sh
权限chmod +x /root/tw.sh
- 通过 pm2 守护进程运行 TiddlyWiki
pm2 start /root/tw.sh
- 保存当前状态
pm2 save
- 设置开机自启
pm2 startup
至此便可以访问首页 Node.js 版本的 TiddlyWiki,并且通过一些方式登录修改了。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK