From KevinWiki

Jump to: navigation, search



Trac is an open-source Issue Tracking System.

Trac Installation

Install Trac 0.11 on Ubuntu Linux 8.10 Intrepid

From the Ubuntu Repository

$ sudo apt-get install trac libapache2-mod-python python-mysqldb 

Through easy_install

It requires the following dependencies to be installed beforehand.

$ apt-get install python-pysqlite2 python-subversion python-support python-setuptools libapache2-mod-python python-mysqldb 
  • Install Trac through easy_install in the python-setuptools.
$ sudo easy_install Trac 

Install Trac 0.11 on Ubuntu Linux 8.04 Hardy

  • Install dependencies.
$ sudo apt-get install python-pysqlite2 python-subversion python-support python-setuptools libapache2-mod-python python-mysqldb 
  • Install it.
$ sudo easy_install Trac 

  • Not necessary if using easy_install
  1. *Extract the trac 0.11 archive file downloaded from the trac web-site.
# $ tar -xzvf Trac-0.11.1.tar.gz 
  1. *Install it.
# $ cd Trac-0.11.1 
# $ sudo easy_install Trac 

Preparation for Project Creation

-To set up and use trac,

  1. Trac project directory should be created.
  2. Trac project directory info should be added to apache2 sites-enabled.
  3. Database for the Trac should be created.

Create Project Directory

-To set up a trac project, create a directory for the project.

$ sudo mkdir /opt/trac 
$ sudo chown www-data:www-data /opt/trac 

-Create available site info for trac

$ cd /etc/apache2/sites-available 
$ sudo vim trac 

Add Project Info to Apache

-Add the following lines

    <Location /trac>
        SetHandler mod_python
        PythonInterpreter main_interpreter
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /opt/trac
        PythonOption TracUriRoot /trac
#        PythonOption PYTHON_EGG_CACHE /tmp
        SetEnv PYTHON_EGG_CACHE /tmp

    <LocationMatch "/trac/[^/]+/login">
        AuthType Basic
        AuthName "Trac"
        AuthUserFile /etc/subversion/.passwd
        Require valid-user

-SSLRequireSSL is to use SSL for accessing the Trac project.

-If PythonOption PYTHON_EGG_CACHE /tmp does not work and the following errors are displayed, use SetEnv PYTHON_EGG_CACHE /tmp instead.


ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg

  [Errno 13] Permission denied: '/var/www/.python-eggs'

The Python egg cache directory is currently set to:


Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

-Enable it and reload apache2 config or restart it.

$ sudo a2ensite trac 
$ sudo /etc/init.d/apache2 reload 
$ sudo /etc/init.d/apache2 restart 

Create the Database and Setup the User

-Create the database for the trac.


-Check if its character set is correct

mysql> USE trac; 
Database changed
mysql> SHOW VARIABLES LIKE '%character%'; 
| Variable_name            | Value
| character_set_client     | cp1251
| character_set_connection | cp1251
| character_set_database   | utf8
| character_set_filesystem | binary
| character_set_results    | cp1251
| character_set_server     | utf8
| character_set_system     | utf8
| character_sets_dir       | C:\DevServer\Instal
8 rows in set (0.00 sec)

-Allocate the admin user of the trac database.

GRANT ALL ON `trac`.* TO `trac`@`localhost` IDENTIFIED BY 'password'; 

-The connection string is


Project Environment Initialisation

-Now initialise project.

$ sudo trac-admin /opt/trac/project initenv 
Creating a new Trac environment at /opt/trac/project                   

Trac will first ask a few questions about your environment 
in order to initalize and prepare the project database.    

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> My Project

 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment 
 directory. It is also possible to use an already existing         
 PostgreSQL database (check the Trac documentation for the exact   
 connection string syntax).                                        

Database connection string [sqlite:db/trac.db]> mysql://trac:password@localhost/trac

 Please specify the type of version control system,
 By default, it will be svn.                       

 If you don't want to use Trac with version control integration, 
 choose the default here and don't specify a repository directory. 
 in the next question.                                             

Repository type [svn]> svn

 Please specify the absolute path to the version control 
 repository, or leave it blank to use Trac without a repository.
 You can also set the repository location later.                

Path to repository [/path/to/repos]> /opt/svn/myproject

Creating and Initializing Project
 Installing default wiki pages   
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracImport imported from TracImport
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracIni imported from TracIni      
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracNavigation imported from TracNavigation
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TitleIndex imported from TitleIndex        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracTimeline imported from TracTimeline    
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracSearch imported from TracSearch        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracWiki imported from TracWiki            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracCgi imported from TracCgi              
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiRestructuredText imported from WikiRestructuredText
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracAdmin imported from TracAdmin                      
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracRoadmap imported from TracRoadmap                  
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiNewPage imported from WikiNewPage                  
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiFormatting imported from WikiFormatting            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/RecentChanges imported from RecentChanges              
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracSupport imported from TracSupport                  
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracRevisionLog imported from TracRevisionLog          
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiDeletePage imported from WikiDeletePage            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracLogging imported from TracLogging                  
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracTicketsCustomFields imported from TracTicketsCustomFields
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracFastCgi imported from TracFastCgi                        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracStandalone imported from TracStandalone                  
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracBackup imported from TracBackup                          
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracAccessibility imported from TracAccessibility            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracNotification imported from TracNotification              
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracModPython imported from TracModPython                    
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracWorkflow imported from TracWorkflow                      
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracChangeset imported from TracChangeset                    
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/CamelCase imported from CamelCase                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracGuide imported from TracGuide                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracBrowser imported from TracBrowser                        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracEnvironment imported from TracEnvironment                
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracRss imported from TracRss                                
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/PageTemplates imported from PageTemplates                    
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/InterMapTxt imported from InterMapTxt                        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiProcessors imported from WikiProcessors                  
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracQuery imported from TracQuery                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/InterWiki imported from InterWiki                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracPermissions imported from TracPermissions                
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/InterTrac imported from InterTrac                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracReports imported from TracReports                        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracTickets imported from TracTickets                        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiStart imported from WikiStart                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiRestructuredTextLinks imported from WikiRestructuredTextLinks
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracLinks imported from TracLinks                                
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiPageNames imported from WikiPageNames                        
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracInstall imported from TracInstall                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracUnicode imported from TracUnicode                            
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracInterfaceCustomization imported from TracInterfaceCustomization
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracPlugins imported from TracPlugins                              
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracUpgrade imported from TracUpgrade                              
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiMacros imported from WikiMacros                                
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracFineGrainedPermissions imported from TracFineGrainedPermissions
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/WikiHtml imported from WikiHtml                                    
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/SandBox imported from SandBox                                      
 /usr/lib/python2.5/site-packages/trac/wiki/default-pages/TracSyntaxColoring imported from TracSyntaxColoring                
 Indexing repository                                                                                                         

Project environment for 'My Project' created.

You may now configure the environment by editing the file:


If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

  tracd --port 8000 /opt/trac/project

Then point your browser to http://localhost:8000/project.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project


-Set the permission.

$ sudo chown -R www-data:www-data /opt/trac 



TracNavigation: The main navigation entries can be edited by [mainnav] and [metanav] configuration sections. e.g.) To change roadmap path from /roadmap to /roadmap?show=all in order to display all the milestones including completed ones, add the following lines to the conf/trac.ini file.

roadmap.href = /roadmap?show=all



trac-admin $ENV repository resync "svn-name"


trac-admin /opt/trac/project repository resync "(default)"

Add the following line to the post-commit file in the svn hook dir (e.g. /opt/svn/project/hooks)

trac-admin $ENV changeset added "$REPOS" "$REV"


trac-admin /opt/trac/project changeset added "$REPOS" "$REV"
trac-admin /opt/trac/project changeset added "repo-name" "$REV"


"$REPOS"/hooks/ commit "$REPOS" $REV "$REPOS"/mailer.conf


# "$REPOS"/hooks/ commit "$REPOS" $REV "$REPOS"/mailer.conf

Git and Gitolite

Install Git Plugin

  • For Trac 0.12
$ easy_install 
$ /etc/init.d/apache2 restart 
  • For Trac 0.11:
  • or alternatively the Python 2.4 backport:


  • Resolve the permission issue
$ addgroup git-readers 
$ usermod -a -G git-readers,www-data git 
$ usermod -a -G git-readers www-data 
$ chown git:git-readers /home/git 
$ chown -R git:git /home/git/repositories 
$ chmod u=rwx,g=rx,o= /home/git 
$ chmod -R u=rwx,g=rx,o=rx /home/git/repositories 
$ su - git 
  • modify /home/git/.gitolite.rc file
$REPO_UMASK = 0077;


$REPO_UMASK = 0022;

# -2 for the group.
# -7 for the others.
$ exit 
$ /etc/init.d/apache2 restart 

Post Hook (This may not work!)

  • Git post-comment hook
$ cd project-repo/.git/hooks  (remote)
$ vim post-commit 
REV=$(git rev-parse HEAD)
trac-admin /some/trac/project changeset added "(default)" $REV
  • for post commit update
$ chown git:git-readers post-receive
$ chmod g+w trac.log

Plugin Installation

There are numerous plug-ins available for Trac.


WebAdmin is web user interface to administrate trac.

  • From 0.11 it is included in the core package so no need to install it.


  • Install the trac:WebAdmin plug-in.
#sudo svn export
$ sudo easy_install 
  • add TRAC_ADMIN permission to the user 'admin' in the project.
$ sudo trac-admin /opt/trac/project/ permission add admin TRAC_ADMIN 
  • create an htpasswd file or an htaccess file for the admin user.


-add below to trac.ini (It is probably only for version 0.10. It has not been checked for 0.9)

webadmin.* = enabled


Change max_daysback value

max_daysback = -1
  • max_daysback Maximum number of days (-1 for unlimited) displayable in the Timeline. (since 0.11)


-To make managing trac account easy, install account manager plug-in. -To see the details, visit the AccountManagerPlugin homepage.


-First make sure you've installed setuptools. $ sudo apt-get install python-setuptools

Then you can install the plugin using the easy_install application.

Note: Windows users will need to add easy_install to their PATH.

For Trac 0.9:

$ sudo easy_install 

For Trac 0.10:

Then install this plugin:

$ sudo easy_install 

For Trac 0.11 / 0.12 (doesn't currently work with 0.11.4, see #4125) (also if necessary, check #899 patch):

$ sudo easy_install 

For Trac 0.12:

 $ sudo easy_install 


  • Make sure virtual host setup for trac has the following info and, the .htpasswd file has a user the username of which is admin. The file must be located in the right place as specified below. Otherwise it will get an error message when logging in.
    <LocationMatch "/[^/]+/login">
        AuthType Basic
        AuthName "Trac"
        AuthUserFile /etc/subversion/.test_passwd
        Require valid-user
  • Access Trac and log in with admin ID.
  • Go to Admin menu and configure Accounts module (probably almost everything expect htpasswd ones and RegistrationModule).
  • Go to Accounts -> Configuration
  • Set HtDigestStore (The file does not have to exist as Trac will create one yet it is better to use the existing htdigest file with the admin user info).
1  HtDigestStore
    filename: /opt/trac/project/conf/.filename.htdigest
    realm: realm_name
  • The /opt/trac/project/conf/.filename.htdigest file can be shared with svn in both apache site setup and SvnServePasswordStore.
-- SvnServePasswordStore
    filename: /opt/trac/project/conf/.filename.htdigest

  • Add the following lines to trac.ini file in the trac_project/conf directory (Not necessary for 0.11)


acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.accountmanager = enabled
acct_mgr.db.sessionstore = enabled
acct_mgr.htfile.abstractpasswordfilestore = enabled
acct_mgr.htfile.htdigeststore = enabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.http.httpauthstore = enabled
acct_mgr.pwhash.htdigesthashmethod = enabled
acct_mgr.pwhash.htpasswdhashmethod = enabled
acct_mgr.web_ui.accountmodule = enabled
acct_mgr.web_ui.loginmodule = enabled
acct_mgr.web_ui.registrationmodule = enabled
trac.web.auth.loginmodule = disabled
webadmin.* = enabled
  • may only need this.
add: trac.web.auth.loginmodule = disabled
  • If email verification is used, also make sure that smtp is enabled.
smtp_enabled = true

  • Not necessary if you set it up through web admin.
htdigest_realm = tectra_trac
password_file = /opt/trac/project/conf/users.htdigest
password_store = HtDigestStore


htdigest_realm = tectra_trac
password_file = /opt/trac/project/conf/users.htpasswd
password_store = HtPasswdStore
  • Optional: change
default_charset = iso-8859-15


default_charset = utf-8

  • Comment out the authentication info of trac in the available sites (/etc/apache2/sites-available/trac).
#  <LocationMatch "/trac/[^/]+/login">
#    AuthType Basic
#    AuthName "Trac"
#    AuthUserFile /etc/subversion/.passwd
#    Require valid-user
#  </LocationMatch>
  • Restart Apache2
$ sudo /etc/init.d/apache2 restart 

Syntax Highlighting Plugin


If syntax highlighting does not work, install Pygments

$ easy_install Pygments 


It is automatically detected and used by trac once it is installed.

Server Side Redirect from a Wiki Page

ServerSideRedirectPlugin is a plugin to automatically redirect a wiki page to another wiki (or web) page.


Install ExtractUrlPlugin

To install Server Side Redirect plug in ExtractUrlPlugin must be installed first.

$ sudo easy_install
Install ServerSideRedirectPlugin
$ sudo easy_install


Open the trac.ini file and add the following lines.

tracserversideredirect.* = enabled
tracextracturl.* = enabled


ColorMacro is a plugin to change the colour of text and background.


Download the macro file

For 0.11:

$ wget 

For 0.12:

$ wget 
Move to Plugins Directory
  • Move the macro file to the plugins directory of the project environment.
$ chown www-data:www-data 
$ mv /trac_env_location/plugins/


[[Color( background-color, color , text )]]
[[Color( color , text )]]
  • none for no colour change.


[[Color(none,red,No background colour change but the text)]]


IniAdminPlugin is a Trac plugin to edit the options in trac.ini file via the WebAdminPlugin.


for 0.11 and 0.12

sudo easy_install 

Note: It may require a restart of the server process to apply the changes.


Issue with python-setuptools


If some warning messages like the following ones appear during installation, user addition, etc.

/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/ UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages)
/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/ UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages)


Re-install python-setuptools

$ rmdir /usr/lib/python2.6/dist-packages/setuptools.egg-info 
$ apt-get install --reinstall python-setuptools


Known Problem with Mylyn


Mylyn, an Eclipse plug-in, is currently not working with Trac 0.11. It does not recognise Trac 0.11 repository.


It can be solved by using XmlRpcPlugin.

-To install (for 0.11 and 0.12),

$ sudo easy_install -Z -U 

-Access the Trac and log in with the admin ID. Go to the Admin menu and enable all the components or the following ones in the TracXMLRPC plug-in.

tracrpc.api.* — License: BSD
  XMLRPCSystem — Core of the RPC system.

tracrpc.json_rpc.* — License: BSD
  JsonRpcProtocol — Example `POST` request using `curl` with `Content-Type` header and body:* — License: BSD
  SearchRPC — Search Trac.

tracrpc.ticket.* — License: BSD
  ComponentRPC — Interface to ticket component objects.
  MilestoneRPC — Interface to ticket milestone objects.
  PriorityRPC — Interface to ticket priority.
  ResolutionRPC — Interface to ticket resolution.
  SeverityRPC — Interface to ticket severity.
  StatusRPC — An interface to Trac ticket status objects. Note: Status is defined by workflow, and all methods except `getAll()` are deprecated no-op methods - these will be removed later.
  TicketRPC — An interface to Trac's ticketing system.
  TypeRPC — Interface to ticket type.
  VersionRPC — Interface to ticket version objects.

tracrpc.web_ui.* — License: BSD
  RPCWeb — Handle RPC calls from HTTP clients, as well as presenting a list of methods available to the currently logged in user. Browsing to <trac>/rpc or <trac>/login/rpc will display this list.* — License: BSD
  WikiRPC — Superset of the [ WikiRPC API].

tracrpc.xml_rpc.* — License: BSD
 XmlRpcProtocol — There should be XML-RPC client implementations available for all popular programming languages. Example call using `curl`:

Note: RPCWeb and XmlRpcProtocol are required for login

OLD (don't need it):

All the components with .ticket

-If the authentication fails, it might be because of the problem with AccountManagerPlugin. It can be solved by using HttpAuthPlugin.



$ sudo easy_install 
httpauth.* = enabled

-To add additional paths for XmlRpc (Optional):

paths = /xmlrpc, /login/xmlrpc

Don't forget to restart the server.

  • Now go to the Permissions menu in the web admin and give the XML_RPC permission to the users who are allowed to access the trac through XML RPC.
  • When accessing the Trac through Mylyn, select XML-RPC Pligin (Rev. 1950) in the 'Additional Settings' as the access type.

Trac with SSL and Virtual Host

-Edit /etc/apache2/sites-available/trac file with the following lines.

<VirtualHost *:443>

    SSLEngine on

    SSLOptions +StrictRequire

    SSLCertificateFile /etc/ssl/certs/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key

#    DocumentRoot /opt/trac

#    <Location /trac>
   <Location />
        SetHandler mod_python
        PythonInterpreter main_interpreter
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /opt/trac
#        PythonOption TracUriRoot /trac
        PythonOption TracUriRoot /
#        PythonOption PYTHON_EGG_CACHE /tmp
        SetEnv PYTHON_EGG_CACHE /tmp
#        SSLRequireSSL

#    <LocationMatch "/[^/]+/login">
#        AuthType Basic
#        AuthName "Trac"
#        AuthUserFile /etc/subversion/.test_passwd
#        Require valid-user
#    </LocationMatch>

  • To use htdigest instead of htpasswd
    <LocationMatch "/[^/]+/login">
        AuthType Digest
        AuthName realm
        AuthUserFile /somepath/.mclicker.htdigest
        Require valid-user
  • Yet this might not be necessary. Better use an htpasswd for accessing trac then use web admin to set up an htdigest file for the user management.

  • Restart Apache2
$ sudo /etc/init.d/apache2 restart 
  • If the authentication type is Digest and there is an error message like this
Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration!
  • Enable auth_digest module.
$ a2enmod auth_digest 

Now trac can be accessed through the URL so the project URL in the Trac will be like below.
Personal tools