How to install trac service on Ubuntu for multiple projects using Mod_Python.

Trac LogoPreviously I have installed a DNS service on my Ubuntu server. Today I would like to install a Trac service which supports for multiple projects using Mod_Python on Apache.


Condition :

  1. I would like to use sub-domain for trac service that is trac.aoddy.com
  2. Trac service can support multiple projects such as trac.aoddy.com/Project1, trac.aoddy.com/Project2
  3. Trac service supports SVN service too.


[ad#ad-post-1]
Softwares :

  1. enscript
  2. libapache2-mod-python
  3. python-docutils
  4. trac
  5. db4.3-util
  6. libapache2-svn
  7. subversion-tools

You can install software by

$ sudo apt-get install enscript libapache2-mod-python python-docutils trac db4.3-util libapache2-svn subversion-tools

Install & Configurations :

  1. Create SVN directory such as :
    $ sudo mkdir /svn
  2. Set SVN directory to repository.
    $ sudo svnadmin create /svn
  3. Create a user account so as to security policy.
    $ sudo htpasswd 2 -cm /etc/apach2/dav_svn.passwd YOUR-ACCOUNT
  4. Create TRAC directory such as :
    $ sudo mkdir /trac
  5. Change owner of TRAC directory to www-data :
    $ sudo chown -R www-data:www-data /trac
  6. Create a configuration file of TRAC in apache
    $ sudo vi /etc/apache2/site-available/trac.aoddy.com
    
    ServerName trac.aoddy.com
    DocumentRoot /trac
    
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonOption TracEnvParentDir /var/lib/trac
    PythonOption TracUriRoot /
    
    
    AuthType Basic
    AuthName "Trac"
    AuthUserFile /etc/apache2/dav_svn.passwd
    Require valid-user
    
    Alias /svn /svn
    
    DAV svn
    SVNParentPath /svn
    SVNListParentPath On
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.passwd
    AuthzSVNAccessFile /etc/apache2/authz_svn.access
    Require valid-user
    
    ErrorLog /var/log/apache2/trac.aoddy.com/error.log
    CustomLog /var/log/apache2/trac.aoddy.com/access.log common
    
  7. Create a directory for keep error log.
    $ sudo mkdir -p /var/log/apache2/trac.aoddy.com/
  8. Add this site into apache service.
    $ sudo a2ensite trac.aoddy.com
    $ sudo /etc/init.d/apach2 restart
  9. Sometime you need to re-configure in this file, I recommend you should use these commands.
    $ sudo a2dissite trac.aoddy.com
    $ sudo a2ensite trac.aoddy.com
    $ sudo /etc/init.d/apach2 restart
  10. Test by open an URL http://trac.aoddy.com/

Create SVN

You can use this script for create a SVN environment.

#!/bin/bash
PROJECTNAME=$1
mkdir -p /tmp/${PROJECTNAME}/branches /tmp/${PROJECTNAME}/tags/ /tmp/${PROJECTNAME}/trunks
svnadmin create /svn/${PROJECTNAME}
svn import /tmp/${PROJECTNAME} file:///svn/${PROJECTNAME} -m "initial import"
sudo rm -rf /tmp/${PROJECTNAME}

Don’t remember to change mode of this script to execute file and run this script by root permission.

Create TRAC

$ sudo trac-admin /trac/YOUR-PROJECT-NAME initenv

After you run this command you should find some question about your project

the project name (YOUR-PROJECT-NAME)
use the default database connection string (sqlite:db/trac.db)
the path to svn repository (/svn/YOUR-PROJECT-NAME)
use the default Trac templates directory (/usr/share/trac/templates)

Change permission of this project so as to support apache service

$ sudo chown -R www-data /trac/YOUR-PROJECT-NAME

Woowww, you should find your new project on trac service at http://trac.aoddy.com/YOUR-PROJECT-NAME
[ad#ad-post-1]

0 0 vote
Article Rating
2 Comments
Inline Feedbacks
View all comments
Imam
12 years ago

Nice to see this Blog

broken
broken
12 years ago

um, trying to follow your guide. not working well. on step 9 the restart fails. I have tried this several times but to no avail. dang. 🙁