Trac on CentOS

I have seen Trac before but until recently never really used it. In a project I've been working on with Codename:Tuesday we've been using Trac as the central source for bugs / tickets, documentation, UCTs etc. It's a very nice tool, with SVN integration and a ticketing system that has just what you need for development.

I run a server on CentOS and had a little trouble getting my install to work, so I decided to post this guide to getting trac up and running. This setup will allow you multiple instances of trac sites to support different projects. At the time of writing, my server runs CentOS 4.5 final.

This guide assumes all trac instances will exist under /srv/trac and all subversion instances will exist under /srv/svn and assumes you have subversion, apache and python installed.

Before you start, disable SELinux.

Repositories If you don't have them already, add Karanbir Singh's repositories:

Add the gpg key:

Install the prerequisites for Trac:

yum install mod_dav_svn mod_python clearsilver python-clearsilver python-sqlite trac

Add the following to your apache httpd.conf:

# load relevent modules
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
LoadModule python_module modules/mod_python.so

<VirtualHost *:80>
...
### trac
Alias /trac/ "/srv/trac/"
<Directory "/srv/trac">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

# mod_python speeds things up considerably
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir "/srv/trac"
PythonOption TracUriRoot "/trac"

# authentication
AuthType Digest
AuthName "wiki-server"
AuthDigestDomain /trac
AuthDigestFile "/etc/httpd/conf/digestpw"
Require valid-user
# authorization is handled internally by trac
</Directory>

### subversion
<Location "/svn">
DAV svn
SVNParentPath /srv/svn

Order allow,deny
Allow from all

# authentication
AuthType Digest
AuthName "wiki-server"
AuthDigestDomain /svn
AuthDigestFile "/etc/httpd/conf/digestpw"
Require valid-user

# authorization
AuthzSVNAccessFile "/etc/httpd/conf/svn-auth.ini"
</Location>
</VirtualHost>

Setup your svn instance:

svnadmin create /srv/svn/myproj --fs-type fsfs
chown -R apache /srv/svn/myproj
chmod -R go-rwx /srv/svn/myproj

Run the following commands to create a trac instance (replacing "myproj" with the name of your project):

trac-admin /srv/trac/myproj initenv
chgrp -R apache /srv/trac/myproj
chown -R apache /srv/trac/myproj/{attachments,db,log}
chmod -R o-rwx /srv/trac/myproj

Remove anonymous write access to Trac:

trac-admin /srv/trac/myproj permission remove anonymous TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY

add admin user priveledges:

trac-admin /srv/trac/myproj permission add myuser TRAC_ADMIN

setup special privs for other priveledged users

trac-admin /srv/trac/myproj permission add cooluser WIKI_DELETE

tweak everyone's base priveledges:

trac-admin /srv/trac/myproj permission add authenticated \
BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW \
REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW \
TICKET_CREATE TICKET_MODIFY TICKET_VIEW TIMELINE_VIEW \
WIKI_CREATE WIKI_MODIFY WIKI_VIEW

setup svn authorization; create the file /etc/httpd/conf/svn-auth.ini) with the following contents:

[groups]
projectadmins = adminuser1, adminuser2
othercoolfolks = projectuserA, projectuserB, projectuserC

# repository (r = read, w = write, or none)
[myproj:/]
@projectadmins = rw
@othercoolfolks = rw
* = r

[myproj:/admin-only/]
@projectadmins = rw
@othercoolfolks = r

Create the password file and add a password for the admin user:

htdigest -c /etc/httpd/conf/digestpw wiki-server adminuser

Create passwords for any other users:

htdigest /etc/httpd/conf/digestpw wiki-server user

Restart apache, and now you should be able to access your project at http://server/trac/myproj - login with the user and password you just setup and bob's yer wossname.

CAVEAT: you may find when you load the trac page you see "Error: Unsupported File Format". If you do, you need to disable the pdo_sqlite module as it's likely conflicting with the version installed by python. Edit the file /etc/php.d/pdo_sqlite.ini and comment out anything in the file by putting a # symbol at the beginning of each line.

Credits: I got a lot of this from here so many thanks to the original author - I've just modified a little and added more basic instructions.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.tobytremayne.com/trackback.cfm?EB6D1570-0C7D-32AD-5AD94D016D366097

Comments
Vincent's Gravatar Great, thanks for the CAVEAT notice about PHP' pdo_mysql. Was beginning to pull y hairs on this one when I found your article...
# Posted By Vincent | 8/23/07 6:25 AM
Vincent's Gravatar bah, pdo_sqlite...
# Posted By Vincent | 8/23/07 6:50 AM
Dave's Gravatar Thanks for the walkthrough. Just wanted to mention that I had trouble restarting httpd. In your httpd.conf there is a 'AuthDigestFile'. On my setup I had to change this to 'AuthUserFile'. Hope this helps.
# Posted By Dave | 10/23/07 12:23 PM
Pez's Gravatar hi, thanks for your work. question for you, which version of python was installed when you did this installation?
# Posted By Pez | 11/25/07 11:28 PM
needfornews's Gravatar Try NeedForNews.com, a new comprehensive news aggregator. With NeedForNews, you don ’t really have to go anywhere else; NeedForNews has it all.
http://needfornews.com/top_search.php
http://vidslib.com/
# Posted By needfornews | 3/26/08 8:47 AM
Carl Samson's Gravatar I am getting command not found when creating trac environment trac-admin
# Posted By Carl Samson | 3/29/08 6:42 AM
rssnewsdigest's Gravatar Try rssnewsdigest.com, a new comprehensive news aggregator. With NeedForNews, you don ’t really have to go anywhere else.
http://rssnewsdigest.com
http://realwebnews.com/
# Posted By rssnewsdigest | 4/2/08 5:17 AM
feedogator's Gravatar We search Feeds For You
http://feedogator.com/
# Posted By feedogator | 4/10/08 4:30 AM