In this tutorial we will guide you through the steps of installing and running TiddlyWiki on a CentOS 6 VPS.
We will also install and configure Nginx as a reverse proxy, so you can run TiddlyWiki behind Nginx.
What is TiddlyWiki?
It is an open-source single page application wiki. The content is divided into a series of components called Tiddlers.
UPDATE THE SYSTEM
Make sure you are in a screen session and check if your Linux VPS is fully up-to-date by running:
## screen -U -S tiddlywiki-screen ## yum update
INSTALL DEVELOPMENT TOOLS
We need some development tools on the system in order to build NodeJs
. Install the Development Tools
meta package using yum
## yum groupinstall "Development Tools"
INSTALL NODEJS
Compile and install NodeJs
using the following commands:
## mkdir -p /opt/build ## cd /opt/build ## wget http://nodejs.org/dist/node-latest.tar.gz ## tar xzvf node-latest.tar.gz ## cd node-v* ## ./configure ## make ## make install
INSTALL AND SET-UP TIDDLY WIKI
Install TiddlyWiki
with the following command
## npm install -g tiddlywiki
Check TiddlyWiki is installed by executing
## tiddlywiki --version
Create user for tiddlywiki
## useradd -m tiddlywiki ## su - tiddlywiki
Set-up a new wiki using
## tiddlywiki mywiki --init server ## tiddlywiki mywiki --server
tiddlywiki
can be invoked like this
tiddlywiki --server <port> <roottiddler> <rendertype> <servetype> <username> <password> <host>
where the parameters are:
- port – port number to serve from (defaults to “8080”)
- roottiddler – the tiddler to serve at the root (defaults to “$:/core/save/all”)
- rendertype – the content type to which the root tiddler should be rendered (defaults to “text/plain”)
- servetype – the content type with which the root tiddler should be served (defaults to “text/html”)
- username – the default username for signing edits
- password – optional password for basic authentication
- host – optional hostname to serve from (defaults to “127.0.0.1” aka “localhost”)
INSTALL AND SET-UP NGINX
In order to install Nginx in your CentOS 6 linux vps, you need to have EPEL
repository enabled on the system, so enable it using:
## wget -P /tmp http://mirror.itc.virginia.edu/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm ## rpm -Uvh /tmp/epel-release-6-8.noarch.rpm ## rm -f /tmp/epel-release-6-8.noarch.rpm
once EPEL
is enabled on the system, install Nginx
using yum
## yum install nginx
set-up server block
## vim /etc/nginx/conf.d/twiki.conf
server { listen 80; server_name mydomain.tld; # vhost specific logs access_log /var/log/nginx/mydomain.tld.access.log combined; 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; } }
restart nginx and add it to your system’s start-up
## service nginx restart ## chkconfig nginx on
to make TiddlyWiki to be automatically started on system start-up, we need to create the following init script:
## vim /etc/init.d/tiddlywiki
#!/bin/sh # # chkconfig: 35 99 99 # description: tiddlywiki # . /etc/rc.d/init.d/functions USER="tiddlywiki" DAEMON="/usr/local/bin/tiddlywiki" PARAMS="--server" LOCK_FILE="/var/lock/subsys/tiddlywiki" do_start() { if [ ! -f "$LOCK_FILE" ] ; then echo -n $"Starting $SERVER: " runuser -l "$USER" -c "$DAEMON $PARAMS &" && echo_success || echo_failure RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $LOCK_FILE else echo "$SERVER is locked." RETVAL=1 fi } do_stop() { echo -n $"Stopping $SERVER: " pid=`ps -aefw | grep "$DAEMON $SERVER" | grep -v " grep " | awk '{print $2}'` kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE } case "$1" in start) do_start ;; stop) do_stop ;; restart) do_stop do_start ;; *) echo "Usage: $0 {start|stop|restart}" RETVAL=1 esac exit $RETVAL
## chmod +x /etc/init.d/tiddlywiki ## chkconfig tiddlywiki on
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install TiddlyWiki for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
Thank you for featuring TiddlyWiki, much appreciated!
There’s a minor tweak needed since the latest 5.0.8-beta version of TiddlyWiki. The instructions to set up a new wiki should be:
## tiddlywiki mywiki --init
## tiddlywiki mywiki --server
Instead of:
## mkdir mywiki
## cd mywiki
## tiddlywiki --server
The article has been updated. Thanks for your comment.
The is a bug in the code:
Instead of:
tiddlywiki mynewwiki –init
the command should be
tiddlywiki mynewwiki –init server
The first creates a normal “empty” wiki that is made for using in offline mode, it doesn’t use nodejs and you can connect but it doesn’t save anything to the server instead just asks to save offline when you want to close the page. Refusing to do so will erase all changes next time you visit the page.
Source:
http://tiddlywiki.com/static/Installing%2520TiddlyWiki%2520on%2520Node.js.html
Thanks
I wish to configure my wiki to be accessible as a folder under the existing domain
my.domain.com/tiddlywiki and I tried the configuration as follows
location /tiddlywiki/ {
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 tiddlywiki loads in the browser and the basic auth configured also succeeds but, Saving changes fails.
I observe nginx access log that show requests to /recipes/ & /status/ that are failing with 404
Any clue would be appreciated.
@Rajeev:
There is a command-line option `prefix` to pass to `tiddlywiki` so that the folder is appended to requests URLs to the server. More info in the TiddlyWiki Docs:
http://tiddlywiki.com#Using%20a%20custom%20path%20prefix%20with%20the%20client-server%20edition
So I wanted to run several TW on the same machine but inside different folders. I went with the Nginx proxy solution (though I would have preferred Apache since I’ve always used it & never even touched Nginx).
I tried the path prefix solution first (because I didn’t want to make changes to the TW itself) but it failed even after trying all four methods to write path prefix (with & without / at start & end of the path) :
– protocol is http
– host is local (192.168.x.x)
– node is on simple folder (eg.
http://192.168.x.x/node/
)Instance can be accessed as usual on both the direct URL & the proxy URL, but can’t be saved from the proxy URL.
What kind of error do you get? Have you checked your log files?
–server is now deprecated and –listen is replacing it.
Here is my script on Debian (I am not sure about all the parameters of INIT INFO):
#!/bin/sh
### BEGIN INIT INFO
# Provides: tiddlywiki
# Required-Start:
# Required-Stop:
# Default-Start: 5
# Default-Stop:
# Short-Description: Start tiddlywiki server.
# Description: Start tiddlywiki server.
### END INIT INFO
. /lib/lsb/init-functions
USER=”tiddlywiki”
DAEMON=”/usr/local/bin/tiddlywiki”
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=”tiddlywiki”
DESC=”tiddlywiki”
PARAMS=”–listen credentials=credentials readers=pierre writers=pierre”
SERVER=”mywiki”
LOCK_FILE=”/var/lock/subsys/tiddlywiki”
do_start()
{
if [ ! -f “$LOCK_FILE” ] ; then
echo -n $”Starting $SERVER: ”
runuser -l “$USER” -c “$DAEMON $SERVER $PARAMS &” && echo success || echo failure
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
else
echo “$SERVER is locked.”
RETVAL=1
fi
}
do_stop()
{
echo -n $”Stopping $SERVER: ”
pid=`ps -aefw | grep “$DAEMON $SERVER” | grep -v ” grep ” | awk ‘{print $2}’`
kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
}
case “$1″ in
start|”)
do_start
;;
stop)
do_stop
;;
restart)
do_stop
do_start
;;
*)
echo “Usage: $0 {start|stop|restart}”
RETVAL=1
esac
exit $RETVAL
I added credentials so my wiki is private.
I had to run sudo update-rc.d tiddlywiki defaults to make it start at startup.