install-and-run-tiddlywiki-on-a-centoos-6-vps-using-nginxIn 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.