Install and run TiddlyWiki on a CentoOS 6 VPS using Nginx

Leave reply

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.

 


50% OFF Coupon

EXCLUSIVE EMAIL UPDATES AND “MEMBERS-ONLY” CONTENT


6 Responses to “Install and run TiddlyWiki on a CentoOS 6 VPS using Nginx”

  1. Jeremy Ruston

    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

    Reply
  2. Basilmir

    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

    Reply
  3. Rajeev B

    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.

    Reply

Leave a Reply