This is a example OpenBSD 3.9 installation of Instiki wiki using lighttpd and fastCGI as front end. The instiki wiki is used as a public web page for my local surf club (SurfclubKlagshamn). Instiki is a Ruby On Rails application which uses a MySQL database for persistent storage. Everything is free for non-commercial use as this is.

Many steps are included in the description below but most likely not all. Anyway this could probably be used as some guidance when trying to setup a similar server as I did.

Install OpenBSD 3.9

Install base installation (all sets) of OpenBSD 3.9.

Add user peter

# adduser

Note: Invite into wheel group

Install source and ports collection

# mkdir /mnt/cdrom
# mount -t cd9660 -r /dev/cd0a /mnt/cdrom/
# cd /usr
# cp /mnt/cdrom/ports.tag.gz /usr/
# tar -xzvpf ports.tar.gz
# cd /usr/src
# cp /mnt/cdrom/src.tag.gz /usr/src
# cp /mnt/cdrom/sys.tag.gz /usr/src
# tar -xzvpf src.tar.gz
# tar -xzvpf sys.tar.gz

Add cdrom to fstab

Add the following line to /etc/fstab

/dev/cd0a /mnt/cdrom cd9660 ro,noauto 0 0

Add nano text editor

# pkg_add

Add default package handling for root

Add the following lines in /root/.profile (use nano)

# Package handling

Enable permissions in system control

Allow port forwarding IPv4, IPv6

Setup pf.conf

See PF_CONF file for an example

Install ddclient from source

# cd /usr/ports/net/ddclient
# make install

Install precompiled/downloaded packages

# set PKG_PATH = /mnt/cdrom/3.9/packages/i386/ 
# pkg_add jdk-1.4.2p7.tgz
# pkg_add samba-3.0.21bp2.tgz
# pkg_add tcl-8.4.7p1.tgz
# pkg_add expect-5.43.0p0.tgz
# pkg_add tk-8.4.7.tgz
# pkg_add sqlite3-3.2.8p0.tgz
# pkg_add sqlite3-tcl-3.2.8p0.tgz

Add local man page

# cp /mnt/cdrom/other/local.0 /usr/local/man/cat1/local.0

Install RubyOnRails


Install Ruby

# pkg_add ruby-1.8.4p1.tgz

Install gems

# tar xvzf rubygems-0.8.11.tgz
# cd rubygems-0.8.11
# ruby setup.rb

# pkg_add ruby-iconv

# gem install rails
# gem install \RedCloth

Install fastCGI

# pkg_add fcgi-2.4.0p1.tgz
# gem install fcgi

Install MySQL

# pkg_add mysql-client-5.0.21.tgz
# pkg_add mysql-server-5.0.18.tgz

Set root password

# mysql -u root -p

(press enter i.e. empty password)

mysql> SET PASSWORD FOR root@localhost=PASSWORD('pw');
mysql> exit

Add database for instiki

# mysql -u root -p
<enter 'pw'>
mysql> create database instiki_test;
mysql> grant all privileges on 'instiki_test'.* to 'peter'@'localhost' IDENTIFIED BY '<password>';
mysql> exit

Install Lighttpd

# pkg_add lighttpd-1.4.10p1
# mkdir /var/www/pages
# mkdir /var/www/pages/rails
Edit /etc/lighttpd.conf

Install testapp

# cd /var/www/pages/rails
# tar xzvf testapp.tgz

Change rails version in /config/environment.rb

Restart lighttpd

# pkill lighttpd
# lighttpd -f /etc/lighttpd.conf

Open browser to http:/

Install Instiki

# cd /var/www/pages/rails/
# cp /root/download/instiki-0.11.0.tgz .
# tar xzvf instiki-0.11.0.rgz
# mv instiki-0.11.0 instiki

Change first line of instiki/public/dispatch.fcgi to


Add the following line in to instiki/config/environment.rb

ActionController::AbstractRequest.relative_url_root = "/instiki" 

Migrate database to MySQL tables

# cd /var/www/pages/rails/instiki
# rake migrate

Edit /instiki/config/database.yml to point to MySQL

Initialize wiki web

# cd instiki
# (not the port that it is started on)

Go to http:/<port>/

Wiki name: wiki password: pw

Edit /etc/rc.local to start MySQL, lighttpd and ddclient

Transfer wiki

# cd instiki
# mv app app_old
# cp ../instiki_klagshamn/app .
# cp ../instiki_klagshamn/public/stylesheets/* public/stylesheets
# cp -R ../instiki_klagshamn/public/images/static/ public/images/

Change references in /app/views/layouts/default.rhtml

<div id="Header">
  <img src="/instiki/images/static/header_image.jpg">
</div> <!-- Header -->

<div align="center">
  <table class="hidden_table" border="0" width="660">
    <td class="hidden_table" colspan="2" vertical-align="left">
      <% if @show_page_navigation %>
        <div class="page_navigation" align="left">
          <div class="navigation">
            <a href="/instiki/wiki/show/HomePage">Hem</a> |

Restart _lighttpd_

# pkill lighttpd
# lighttpd -f /etc/lighttpd.conf

Install zip/unzip

# ftp
# pkg_add ./zip-2.3p0.tgz
# ftp
# pkg_add ./unzip-5.52.tgz

Install batik

# cd /usr/local/share/
# ftp
# unzip

Test batik

# cd batik-1.6/samples
# java -Djava.awt.headless=true -jar ../batik-rasterizer.jar ./barChart.svg

Configure DNS, order domain etc.

  • Add a “Custom DNS” account at DynDNS
  • Order Beginner Linux webhotel at
  • Change DNS för host to DynDNS instead of Crystone.

Temprary password must be obtained using reset mail address att NIC-SE.

(change takes about 24h to take effect)

Configure DNS at DynDNS

Let DynDNS point at local webserver for web traffic and Crystone servers for mail traffic.

A records  Dynamic IP            # WWW  Static IP    # Mail  Static IP

MX records

CNAME records                # WWW         # Mail

Check information at

Setup local mail client

Incoming (POP3) server: (port 110) Outgoing (SMTP) server: (port 25)

password: postmaster_pw
password: info_pw

Automate backups of Instiki

  • Create backup script (

  • Configure sftp on server to accept empty password

  • Create host key pair. Run the following in host machine

    # ssh-keygen -t dsa (set empty passphrase)

  • Upload public key, ~/.ssh/, to backup server using e.g. sftp.

  • Add contents to ~/.ssh/authorized_keys (file may not exist and must then be created)

bla, bla

cat >> .ssh/authorized_keys

bla, bla

  • Add file to /etc/weekly script

Peter Ljung 2006 (C)