SCM Example Trac

From ArchWiki
Revision as of 11:37, 21 May 2012 by Kynikos (Talk | contribs) (rm gap)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

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