Search

January 20, 2013

Trac on CentOS 6.3, Part 1

Recently I had the need to set up a Trac instance on a 64-bit machine running CentOS 6.3. For CentOS and Red Hat 5, someone has done the hard work already and set up RPM files (see the Trac documentation on RHEL 5 and Dag Wieers RPM repository for details) making installing Trac as easy as yum install trac. Unfortunately, our benefactors have not gotten to RHEL 6 yet so I needed to do it myself.

I am using PostgreSQL for the Trac database. I will assume you already have PostgreSQL up and running. If you are using a different database backend, you should be able to follow along anyway.

First, we need to install some prerequisites:

yum install python-setuptools python-genshi python-pygments \
            subversion-1.6.11-7.el6.i686

Note that the last package in the list there is the 32-bit version of subversion. This is necessary for the python subversion bindings. It is fine if you install (or have already installed) the 64-bit version of subversion as well. If you are not planning on using Trac with a subversion repository you can leave this out. If it bugs you to install 32-bit software on your 64-bit server, you could try to compile the python subversion bindings yourself using SWIG. (If you do and you blog about, let me know and I’ll link to it here.)

Next there are a couple of PostgreSQL-specific prerequisites, specifically the software that allows Python to talk to PostgreSQL:

yum install python-psycopg2 python-psycopg2-doc

Now we can finally start installing Trac and the pieces that go with it. I hit an issue with the latest version of Genshi (as of this writing) and had to force it to use version 0.6.

easy_install Genshi==0.6
easy_install Trac

Next we create initialize a Trac project. You will be prompted for the name and the database connection string. For PostgreSQL, use postgres://username:password@server:5432/database?schema=schema, replacing the initialized values.

mkdir -p /var/trac/myproject
chmod -R 775 /var/trac

trac-admin /var/trac/myproject initenv

Finally we can connect Trac to our Subversion repository. Edit /var/trac/myproject/conf/trac.ini:

[components]
tracopt.versioncontrol.svn.* = enabled

[trac]
repository_dir = /path/to/svn/repository

In part 2, we set up Apache as a front-end and handle some SELinux issues. In part 3, we configure Trac to authenticate against an Active Directory domain (assuming the server has Samba installed and configured to be part of the domain).