SCM Example Trac

From ArchWiki
Jump to: navigation, search

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Not updated for over 3 years, trac is at 1.0.5 as of September 2015 (Discuss in Talk:SCM Example Trac#)

The HOWTO teaches you to setup multi-project Trac/Subversion for a private and trusted environment (ex: a development team).

Updated for Trac 0.11

Basic Environment

Subversion URL:
Trac URL:
PostgreSQL, with trust authentication method
Configuration files are in /mnt/rpo/conf
Subversion repositories is in /mnt/rpo/svn
Trac project files is in /mnt/rpo/trac


Required Packages

Install the following packages:

  • apache
  • mod_python (AUR package)
  • postgresql
  • pypgsql
  • python2-psycopg2 / python-psycopg2 (depends on python version)
  • setuptools
  • subversion
  • trac

Post-Install Steps

Disable connection pooling

Edit /usr/lib/python2.5/site-packages/trac/db/

 class PostgreSQLConnection
   poolable = False   # Change this line

Install webadmin plugin

This is no longer needed, starting with version 0.11 it has been incorporated into the core system

 svn co
 cd webadmin
 python bdist_egg
 easy_install -Z dist/*.egg

Setup Basic Environment

Create the directories:

 mkdir -p /mnt/rpo/conf
 mkdir -p /mnt/rpo/svn
 mkdir -p /mnt/rpo/trac

Set permissions

The user account under which the web server runs will require write permissions to the environment directory and all the files inside. With the web server running as user http and group http, enter:

 chown -R http.http /mnt/rpo

Create User List

Create a new list and add initial user:

 htdigest -c /mnt/rpo/conf/svn-user svnrepos FIRST_USER

To add other users:

 htdigest /mnt/rpo/conf/svn-user svnrepos OTHER_USER

You can edit the svn-user file to remove or rename users

Create Database

Create the trac user and the database:

 /etc/rc.d/postgresql start
 psql -U postgres postgres
 postgres=# CREATE USER trac;
 postgres=# CREATE DATABASE trac OWNER = trac;
 postgres=# \q

Configure Web Server

Edit /etc/httpd/conf/httpd.conf:

 LoadModule dav_module              modules/
 LoadModule dav_svn_module          modules/
 LoadModule python_module           modules/
 # Inside some virtual host if the server is not dedicated to scm
 DocumentRoot "/var/empty"
 <Location />
   Require valid-user
   AuthType Digest
   AuthName "svnrepos"
   AuthDigestProvider file
   AuthUserFile /mnt/rpo/conf/svn-user
 <Location /svn>
   DAV svn
   SVNParentPath /mnt/rpo/svn
   SVNPathAuthz off
 <Location /trac>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /mnt/rpo/trac
   PythonOption TracUriRoot /trac

Create Projects

Each project is consisted of one subversion repository and one trac project, with independent wiki and access control.

Create Subversion Repository

Just execute one line:

 svnadmin create /mnt/rpo/svn/MY_PROJECT

Create Trac Project

  • Initialize project dir:
 trac-admin /mnt/rpo/trac/MY_PROJECT initenv
Database connection string: postgres://trac:password@localhost/trac?schema=MY_PROJECT
(each project must be given an unique schema; no need to create the schemas first)
  • Grant admin permission to all logon users:
 trac-admin /mnt/rpo/trac/MY_PROJECT permission add authenticated TRAC_ADMIN

Modify the /mnt/rpo/trac/MY_PROJECT/conf/trac.ini file

  • Change repository_type to svn
  • Change repository_path to /mnt/rpo/svn/MY_PROJECT
  • Change default_charset to utf-8 or other encodings.
echo -e "[components]\nwebadmin.* = enabled" >> /mnt/rpo/trac/MY_PROJECT/conf/trac.ini