Software installation
All required packages are installed by the following command:
apt-get install lighttpd trac subversion apache2-utils
We install lighttpd together with trac, as otherwise the trac package will pull in an installation of apache2, which is a bit more heavyweight than what I wanted.
Setting up the directory tree
Let’s set up a directory tree for trac:
for p in env svn auth; do mkdir -p /srv/trac/$p/demo; done
One directory for the trac environment data, another for the subversion repository and the third for authentication data. Putting all environments into a single directory (/srv/trac/env) would allow to run a single trac server for all environments using the TRAC_ENV_PARENT_DIR configuration variable.
Creating a trac environment
The trac environment is created using
trac-admin /srv/trac/env/demo initenv
The command will ask interactively for the following settings:
- Project name: Enter a name as you like (“Demo”). Note that you can change this later.
- Database connection string: You can accept the default sqlite database.
- Repository type: I used the default “svn” selection.
- Path to repository: /srv/trac/svn/demo
From now on, we can access the (empty) trac instance by running tracd --port 8000 /srv/trac/env/demo and accessing the trac-integrated web server at port 8000 of the server. Hit Ctrl-C to kill the tracd after you don’t need it any longer.
Creating an initial user
By default, trac creates no users. Only anonymous access is allowed, which by default is read-only. Therefore, we have to create a user to add content. Let’s use digest authentication:
htdigest -c /srv/trac/auth/demo/users "trac demo realm" admin trac-admin /srv/trac/env/demo permission add admin TRAC_ADMIN
You can now start tracd with authentication:
tracd --port 8000 \
--auth=demo,/srv/trac/auth/demo/users,"trac demo realm" \
/srv/trac/env/demo
Configure lighttpd
To use lighttpd to serve the trac environment, we first need to fix the permissions:
chown -R www-data /srv/trac/env chmod +x /usr/share/pyshared/trac/web/fcgi_frontend.py
I think, the second command should not be required and filed Debian bug #510441 because of this.
Next, we need a configuration file. It delegates the trac path to a FastCGI handler and contains the location of the authentication data. Copy the configuration file to /etc/lighttpd/conf-available/ and enable the configuration:
lighty-enable-mod auth trac-demo /etc/init.d/lighttpd force-reload
The trac instance should be available at http://HOSTNAME/trac. Have fun!
Automatic setup
For my own tests I wrote a script which does most of this automatically. Use at your own risk!
BTW: All of this was tested against Debian lenny (not released at time of writing).