Chapter 5. Wigwam Walkthroughs

Table of Contents
Study A: Simple Database-Driven Website
Study B: Simple Apache-JServ Website

It is often easiest to learn by example, so in this chapter we invent several fictitious Wigwam users to show how we intend Wigwam to be used. These walkthroughs may be read in any order.

Study A: Simple Database-Driven Website

Suppose we wish to set up a webserver that will use CGI scripts to make pages from a MySQL database.

Study A: Starting the Project

First we make a new Wigwam project and install the appropriate services:
        wigwam-bootstrap --project=project-name
        cd project-name
        cvs import project-name start wigwam
        cd ..
        rm -rf project-name
        cvs co project-name
        cd project-name
        ./autogen.sh
        . ./setup-env
        packagectl install service_static_apache - service_mysqld
The - indicate that the latest version of service_static_apache should be installed.

Now we need to configure the services; this will consist of setting environment variables for the cluster, the role and the project. First we recommend flushing out the developer role (and sometimes a developer cluster is useful...). First, mark that you are in that role:
     echo developer >! etc/role
Run
        servicectl check-config role --verbose
and it will tell you the environment variables you must set from that script, along with their descriptions if the package has descriptions:
        developer: static_apache: needed OUTSIDE_HOSTNAME
        developer: static_apache: needed OUTSIDE_PORT
        developer: static_apache: needed STATIC_HTTPD_PORT
        developer: static_apache: needed SERVER_ADMIN
        developer: static_apache: needed LOG_DIR
        developer: mysqld: needed MYSQLD_DATA_DIR
        developer: mysqld: needed MYSQLD_PORT

To make things work, you must set these up in a cluster, role or project file. There are many possible ways, but sometimes we do it this way. Each port is relative to a PORT_PREFIX. Usually PORT_PREFIX will be defined on a cluster-wide basis, but for the developer role, it may as well be in the role's early configuration file, etc/roles/ROLE/config.pre:

Note

The etc/roles/ROLE/config is sourced after etc/project.conf, so it cannot be used here, since we want to put the specific services ports in etc/project.conf.

or in etc/project.conf.pre.local. So:
          echo 'PORT_PREFIX=80' >> etc/roles/developer/config.pre
And add to etc/project.conf:
if test "x$PORT_PREFIX" = "x" ; then
  echo "$0: You must define PORT_PREFIX must before you source project.conf" 1>&2
  exit 1
fi
STATIC_HTTPD_PORT=${PORT_PREFIX}80
MYSQLD_PORT=${PORT_PREFIX}81
Then there are just three more variables to deal with, all of which we'll add into the developer role, in etc/roles/developer/config:
OUTSIDE_HOSTNAME=`hostname -f`
OUTSIDE_PORT=${PORT_PREFIX}80
LOG_DIR=$LOCAL_VAR/logs
MYSQLD_DATA_DIR=$LOCAL_VAR/mysqld
SERVER_ADMIN="$USER@$OUTSIDE_HOSTNAME"

Now you can being adding web pages in www/htdocs/.