Description: Cherokee is a flexible, very fast, lightweight Web server. It is implemented entirely in C, and has no dependencies beyond a standard C library. It is embeddable and extensible with plug-ins. It supports on-the-fly configuration by reading files or strings, TLS/SSL (via GNUTLS or OpenSSL), virtual hosts, authentication, cache friendly features, PHP, custom error management, and much more.
Keywords: cherokee web server httpd http

## Index → Cookbook

## Cookbook: Setting up Trac

This recipe will install Trac: an integrated SCM and Project Management solution that gets along very well with Cherokee.

It is written in Python and can work with Cherokee either using HTTP or SCGI protocols. The recipe will address the second scenario because it is slightly more complex. Should you wish to run it via HTTP, Cherokee would only have to relay the requests to Trac acting as an HTTP reverse proxy and no other configuration would be needed on that end.

### Trac

The software requirements are Python-2.5, easy_install and SQLite-3.3.4 or above. Flup is also required unless you want to use the HTTP-proxy method, and SQLite can be replaced by PostreSQL or MySQL if you wish to do so.

On Debian based Linux distributions, just a couple of commands issued as `root` would suffice to provide the requirements and install Trac.

Quick install

    apt-get install python-genshi python-setuptools python-pysqlite2 python-flup
    easy_install Trac

The package names could slightly vary on different distributions.

The next thing would be defining a project environment:

Project creation

    $ trac-admin /path/to/project initenv

Of course, the path should be changed to whatever suits your needs. You will be prompted for more details.

If you want to configure authentication or simply need more details, refer to the Trac installation instructions on the official site.

### Cherokee

The configuration on Cherokee’s side is quite simple. In fact, the configuration of Cherokee is so simple that you only have to click on the Trac Wizard with Cherokee-Admin. You will be asked for the minimal information required, and everything else will be handled for you.

By now, your Trac installation should be up and running. Try it out!

Complete Trac installation

If you used the Wizard, you can skip the rest of the document. It only details what manual steps must be taken. You might find it interesting to know exactly what the wizard does for you, though.

You will only need to know that you can spawn Trac as an SCGI process.

Command to launch Trac

    /usr/bin/tracd --single-env --protocol=scgi /
    --hostname=localhost --port=4433 /path/to/project

You can either start it manually, or better yet, automatically by letting Cherokee spawn the server whenever it is down. The process is fairly simple.

First we will set up an information source with a local interpreter.

Trac information source

Information sources
Host | Interpreter
--- | ---
localhost:4433 | /usr/bin/tracd --single-env --protocol=scgi \ --hostname=localhost --port=4433 /path/to/project/

If the port was not reachable, the `interpreter` command would be launched and the process would be reinstantiated. Note that, in the definition of the information source, you will have to manually launch the `spawner` if you use a `Remote host` as `Information source` instead of a `Local interpreter`.

After doing this, we will just have to create a new rule managed by the SCGI handler to access Trac. It can be created in a new virtual server, `trac.example.net` for instance, or as a `Directory` rule for a specific path such as `/trac`.

Rules

As you can see, we are opting for the first approach and will only need two rules. The `default` will use the `SCGI handler` as detailed above, associated to the previously created information source.

SCGI handler

The second one will be there to serve the few static files needed to correctly display the Trac interface. Just create it as `Directory` type rule for `/chrome/common` and set it to the `Static files` handler and with a `Document root` that points to the appropriate files: `/usr/share/trac/htdocs/`

Static files