Introduction
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. 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 ftp://ftp.sunet.se/pub/OpenBSD/3.9/packages/i386/nano-1.2.5.tgz
Add default package handling for root
Add the following lines in /root/.profile (use nano)
Package handling
PKG_PATH=ftp://ftp.sunet.se/pub/OpenBSD/3.9/packages/i386/
FETCH_PACKAGES=yes
PKG_CACHE=yes
export PKG_PATH FETCH_PACKAGES PKG_CACHE
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
See RailsOnOpenBSD
Install Ruby, Rails
pkg_add ruby-1.8.4p1.tgz
pkg_add ruby-gems-0.8.11.tgz
pkg_add ruby-iconv-1.8.4p1.tgz
gem install rails
gem install \RedCloth
Install fastCGI
pkg_add fcgi-2.4.0p1.tgz
gem install fcgi
Install MySQL
pkg_add mysql-server-5.0.18.tgz
Install default database
/usr/local/bin/mysql_install_db
Set root password
mysql -u root mysql
(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 root;
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
...
RAILS_GEM_VERSION = '1.1.6'
...
Restart lighttpd
pkill lighttpd
lighttpd -f /etc/lighttpd.conf
Open browser to http://192.168.0.6/testapp/say/hello
Install Instiki
cd /var/www/apps/
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 #!/usr/local/bin/ruby
Add the following line in to instiki/config/environment.rb
ActionController::AbstractRequest.relative_url_root = "/instiki"
Migrate database to MySQL tables
cd /var/www/apps/instiki
rake migrate
Edit /instiki/config/database.yml
to point to MySQL
Initialize wiki web
cd instiki
instiki.sh (not the port that it is started on)
Go to http://192.168.0.6:<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> |
...
</div>
</div>
Restart lighttpd
pkill lighttpd
lighttpd -f /etc/lighttpd.conf
Example configuration file for lighttpd.
[[Lighttpd Log Rotation]]
Install zip/unzip
ftp ftp://ftp.sunet.se/pub/OpenBSD/3.9/packages/i386/zip-2.3p0.tgz
pkg_add ./zip-2.3p0.tgz
ftp ftp://ftp.sunet.se/pub/OpenBSD/3.9/packages/i386/unzip-5.52.tgz
pkg_add ./unzip-5.52.tgz
Install batik
cd /usr/local/share/
ftp ftp://ftp.sunet.se/pub/www/servers/apache/dist/xml/batik/batik-1.6.zip
unzip batik-1.6.zip
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 Crystone.se
-
Change DNS för host surfclubklagshamn.se to DynDNS instead of Crystone.
(temprary password must be obtained using reset mail address att NIC-SE)ns1.mydyndns.org 63.208.196.92
ns2.mydyndns.org 204.13.249.82
ns3.mydyndns.org 63.209.15.211
ns4.mydyndns.org 213.155.150.206
ns5.mydyndns.org 63.208.196.93
(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
surfclubklagshamn.se 81.226.187.216 Dynamic IP WWW
mailadmin.surfclubklagshamn.se 83.168.245.34 Static IP Mail
webmail.surfclubklagshamn.se 83.168.245.33 Static IP
MX records
mx11.azalea.se
mx13.azalea.se
CNAME records
www.surfclubklagshamn.se surfclubklagshamn.se WWW
mail.surfclubklagshamn.se mail.mailkluster.azalea.se Mail
Check information at http://www.dnsreport.com/tools/dnsreport.ch?domain=surfclubklagshamn.se
Setup local mail client
Incoming (POP3) server: mail.surfclubklagshamn.se (port 110)
Outgoing (SMTP) server: mail.surfclubklagshamn.se (port 25)
user: postmaster@surfclubklagshamn.se
password: postmaster_pw
user: info@surfclubklagshamn.se
password: info_pw
Automate backups of Instiki
-
Create backup script backup.sh
-
Configure sftp on server to accept empty password
-
Create host key pair. Run the following in host machine
ssh-keygen -t dsa
Set empty pass phrase.
- Upload public key, id_dsa.pub
, to backup server using e.g.
sftp`. - Add
id_dsa.pub
contents toauthorized_keys
(file may not exist and must then be created)
dummy text ...
cat id_dsa.pub >> .ssh/authorized_keys
- Add
backup.sh
file to/etc/weekly
script.
Shell script for backup of MySQL databases mysql_dump.sh
Other tasks
- [[Compile JDK]]
- [[Install Postfix]]
- [[Install Jettt6]]
- [[SMB Setup]]
- PowerNow
- [[Transfer Rails Application]]
- Software Review for OpenBSD 3.9
Peter Ljung 2006 (C)