Install Trac on Debian Squeeze

This post aims to provide a step-by-step on how to install Trac in Debian and get it working. These “instructions” were created exactly the way I setup my server. So paths and setup information can be modified for your project. The idea was this: there are many guides out there which provide the same information but in a more generic way; this post provides exact path information and such so that there is concrete, real world example of what needs to be done.

CAUTION: This post is a work in progress so there are many things which might not be properly documented and could have adverse effect.

Install Necessary Applications

sudo aptitude install trac bzr trac-bzr trac-spamfilter postgresql python-psycopg2 apache2 libapache2-mod-wsgi

Prepare Database

sudo vim /etc/postgresql/8.4/main/pg_hba.conf
Add following lines:
local tracdb tracuser password
host tracdb tracuser md5
host tracdb tracuser md5

psql template1 -W postgres
create database tracdb with encoding = 'utf8';
create user tracuser password 'password';
grant all on database tracdb to tracuser;
sudo /etc/init.d/postgresql-8.4 reload

Prepare Directories

cd /media/shared/Admin/
cd /home/codeghar/
mkdir /home/codeghar/trac
cd trac
cd /home/codeghar/trac/
mkdir repo env
cd /home/codeghar/trac/repo/
bzr init

Create Trac Project

cd /media/shared/Admin/env/
cd /home/codeghar/trac/env/
trac-admin $(pwd) initenv
trac-admin /home/codeghar/trac/env/ initenv
Project Name [My Project]> codeghartrac
Database connection string [sqlite:db/trac.db]> postgres://tracuser:password@localhost/tracdb
Repository type [svn]> bzr
Path to repository [/path/to/repos]> /media/shared/Admin/trac/repo

Enable Bazaar with Trac

To get Trac working with bzr, edit the trac.ini file (Hat tip: bzr – trac integration)
vim /media/shared/Admin/trac/env/conf/trac.ini
And add the following two lines, if they don’t already exist
tracbzr.* = enabled

First Test

Check if everything is working as it should be

tracd --port 8000 /media/shared/Admin/trac/repo/

Trac with WSGI and Apache

cd /media/shared/Admin/trac/www/
trac-admin /media/shared/Admin/trac/env/ deploy /media/shared/Admin/trac/www/
trac-admin /home/codeghar/trac/env/ deploy /home/codeghar/trac/www/

Put the following in your Virtual Host:

WSGIScriptAlias / /home/codeghar/trac/www/cgi-bin/trac.wsgi

<Directory /home/codeghar/trac/www/cgi-bin/trac.wsgi>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all

And then reload Apache. Your site is now available at http://yourip/

Hat tip: View of /packages/trac/trunk/debian/README.Debian; bazaar & trac-bzr; Recipe Installing Trac with PostgreSQL on CentOS4.2; Trac and mod_wsgi;


Comments are closed.

%d bloggers like this: