Node.js TiddlyWiki Examples:
- pimgeek's digital garden: 🌱 Learner's Digital Garden
- My digital garden: Bionic Cat Won't Dream of Electronic Cat Food
- What is TiddlyWiki?
Now let's record the deployment process. The prerequisites are having a domain name, a VPS, and basic knowledge of Linux commands.
Install Node.js and TiddlyWiki#
- Update packages
apt update
&apt upgrade
- For RedHat systems, use
yum
- For RedHat systems, use
- Install Node.js
apt install npm
- Install TiddlyWiki globally
npm install -g tiddlywiki
- Check TiddlyWiki version
tiddlywiki --version
- Create TiddlyWiki directory
mkdir ~/wiki
replace "wiki" with desired name - Create basic files in TiddlyWiki directory
tiddlywiki wiki --init server
- Create user credentials file
vim ~/wiki/users.csv
or use nano or other text editor
users.csv file content:
username,password
johndoe,!@#$%^
The first line is mandatory, and the second line contains the username and plain-text password separated by a lowercase comma without any spaces (refer to the official documentation for more details: WebServer Parameter: credentials)
Install Nginx and Let's Encrypt#
If you are familiar with this step, you can skip it. The key is to set up reverse proxy correctly.
- Install Nginx
apt install nginx
- Create and edit proxy server configuration
cd /etc/nginx/sites-available
thenvim example.com
- Replace example.com with your domain name
example.com file content:
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;
}
}
The client_max_body_size entry sets the maximum upload file size.
- Link and enable the proxy server
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled
- Install Let's Encrypt and activate nginx plugin
apt install certbot python3-certbot-nginx
- Create SSL certificate
certbot --nginx
and follow the instructions to set it up - Run TiddlyWiki and access the domain name to test if it starts successfully
tiddlywiki wiki --listen credentials=users.csv "readers=(anon)" "writers=(authenticated)"
- The credentials field specifies the user credentials file name, readers have read-only access (anon refers to anonymous, i.e., any visitor), and writers have read-write access (authenticated reads the users specified in credentials)
Install pm2 and set up background service#
- Install the latest version of pm2 globally
npm install -g pm2@latest
- Prepare TiddlyWiki startup script
vim ~/tw.sh
Script content:
cd /root
tiddlywiki wiki --listen credentials=users.csv "readers=(anon)" "writers=(authenticated)"
- Give tw.sh permission
chmod +x /root/tw.sh
- Run TiddlyWiki as a daemon process using pm2
pm2 start /root/tw.sh
- Save the current status
pm2 save
- Set up auto-start on boot
pm2 startup
Now you can access the Node.js version of TiddlyWiki homepage and make modifications by logging in through some methods.