Setup Trac and Subversion

Setup Trac and Subversion First install packages for both Trac and Subversion. We’ll be using Apache to publish the Subversion repositories

apt-get install python-setuptools trac subversion libapache2-svn

Create the SVN repository directory structure, used to create new repositories later

mkdir /var/svn/
mkdir /var/svn/tmpproject
mkdir /var/svn/tmpproject/branches
mkdir /var/svn/tmpproject/tags
mkdir /var/svn/tmpproject/trunk

Enable the Apache SVN module

a2enmod dav_fs

Create a password file containing users that have access to the Subversion repositories and Trac

ban3
htpasswd -c /etc/apache2/svn.passwd user1
htpasswd /etc/apache2/svn.passwd user2

Edit the apache configurations to enable Trac and Subversion SVN (pico /etc/apache2/sites-enabled/000-default). Add the following lines:

<Location /svn>
DAV svn
SVNParentPath /var/svn
SVNAutoversioning on
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
</Location>

<Directory “/usr/share/trac/htdocs”>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory> Alias /trac “/usr/share/trac/htdocs”
Create a directory for Trac projects

mkdir /var/trac

Create projects Subversion repository

svnadmin create /var/svn/myproject --fs-type fsfs
svn import /var/svn/tmpproject file:///var/svn/myproject -m "initial import"
find /var/svn/myproject -type f -exec chmod 660 {} \;
find /var/svn/myproject -type d -exec chmod 2770 {} \;
chown -R root.www-data /var/svn/myproject

Trac project

trac-admin /var/trac/myproject initenv
find /var/trac/myproject -type f -exec chmod 660 {} \;
find /var/trac/myproject -type d -exec chmod 2770 {} \;
chown -R root.www-data /var/trac/myproject

Configure Apache to publish the new project (pico /etc/apache2/sites-enabled/000-default). Add the following lines:

ban4
ScriptAlias /projects/myproject /usr/share/trac/cgi-bin/trac.cgi
a
<Location "/projects/myproject">
SetEnv TRAC_ENV "/var/trac/myproject"
</Location>
 
<Location "/projects/myproject">
AuthType Basic
AuthName "Trac - myproject"
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
</Location>

Restart Apache

/etc/init.d/apache2 force-reload

Give a user administrator permissions to the project

trac-admin /var/trac/myproject
permission add user1 TRAC_ADMIN

You can now access your Trac project by browsing with your favorite browser to http://localhost/projects/myproject.

To access the Subversion repository you can use any Subversion client. If you’re using Windows, TortoiseSVN would be a good choice.

Leave a Reply

Your email address will not be published. Required fields are marked *