SCM Example Trac
From ArchWiki
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
Contents |
Basic Environment
Network:
- URL: http://scm.example.com
- Subversion URL: http://scm.example.com/svn/MY_PROJECT
- Trac URL: http://scm.example.com/trac/MY_PROJECT
Database:
- PostgreSQL, with trust authentication method
Filesystem:
- Configuration files are in /mnt/rpo/conf
- Subversion repositories is in /mnt/rpo/svn
- Trac project files is in /mnt/rpo/trac
Preparation
Required Packages
Install the following packages:
- apache
- mod_python
- postgresql
- pypgsql
- setuptools
- subversion
- trac
Post-Install Steps
Disable connection pooling
Edit /usr/lib/python2.5/site-packages/trac/db/postgres_backend.py:
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 http://svn.edgewall.com/repos/trac/sandbox/webadmin cd webadmin python setup.py 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
Create User List
Create a new list and add initial user:
htdigest -c /mnt/rpo/conf/scm-user scm FIRST_USER
To add other users:
htdigest /mnt/rpo/conf/scm-user scm OTHER_USER
You can edit the scm-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 lib/apache/mod_dav.so LoadModule dav_svn_module lib/apache/mod_dav_svn.so LoadModule python_module lib/apache/mod_python.so # Inside some virtual host if the server is not dedicated to scm DocumentRoot "/var/empty" <Location /> Require valid-user AuthType Digest AuthName "svnrepos" AuthDigestDomain http://scm.example.com/ AuthDigestProvider file AuthUserFile /mnt/rpo/conf/scm-user </Location> <Location /svn> DAV svn SVNParentPath /mnt/rpo/svn SVNPathAuthz off </Location> <Location /trac> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /mnt/rpo/trac PythonOption TracUriRoot /trac </Location>
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
- Configure code encoding:
- edit /mnt/rpo/trac/MY_PROJECT/conf/trac.ini, change default_charset to utf-8 or other encodings.
- Allow web admin (http://scm.example.com/trac/MY_PROJECT/admin):
echo -e "[components]\nwebadmin.* = enabled" >> /mnt/rpo/trac/MY_PROJECT/conf/trac.ini