I installed Subversion on a CentOS box with Trac, and although there are many, many howto’s on the web none of them seemed to work for my configuration. This is what i did, and worked for me on CentOS 4.

  • Installing Subversion
  • Installing Trac
  • Configuring Apache and Authentication

So, lets begin with installing Subversion. I used the Yum package manager but whether you install it from source or not doesn’t matter that much. We are going to need the packages ’subversion’ and ‘mod_dav_svn’, the last one is for serving Subversion repositories through Apache HTTP Server, which i assume you already have installed.

[root@repobox ~] yum install mod_dav_svn subversion

Thats basicly it for installing, the configuration was where i lost time, now lets continue installing Trac.

I installed Trac also again in combination with Apache, now we need python and mod_python:

[root@repobox ~] yum install python mod_python

And we need the mysql-python plugin so python can connect to MySQL, you can download the tarball from http://sourceforge.net/projects/mysql-python, then compile the package:

[root@repobox ~] tar xvzf mysql-python-tarball
[root@repobox ~] cd mysql-python-dir
[root@repobox ~] python setup.py build && python setup.py install

Install Clearsilver, this is a templating package used by Trac, you can download it from http://www.clearsilver.net/downloads/

[root@repobox ~] tar xvzf clearsilver-tarball
[root@repobox ~] cd clearsilver-dir
[root@repobox ~] ./configure –with-python=/path/to/python && make && make install

Usually the python path is /usr/lib/python2.4 or whatever version you installed

When you have installed all of the above we can continue with installing Trac, first download Trac from http://trac.edgewall.org/wiki/TracDownload

[root@repobox ~] tar xvzf trac-tarball
[root@repobox ~] cd trac-dir
[root@repobox ~] python ./setup.py install

All done, now we can configure both subversion and Trac with Apache, and create some user authentication.

We are going to create config files for apache, vhost and trac:

[root@repobox ~] cd /etc/httpd/conf.d/
[root@repobox ~] touch vhosts.conf

Now, nano subversion.conf and put in the following:

   DAV svn
   SVNParentPath /var/www/svn

   # Limit write permission to list of valid users.

      AuthType Basic
      AuthName "SVN Authorisation"
      AuthUserFile /etc/svn_trac-auth-conf
      Require valid-user

This allows you to view the repository’s using http://example.org/repos

Now first lets create a svn repository

[root@repobox ~] svnadmin create /var/www/svn/projectname
[root@repobox ~] chown -R apache.apache /var/www/svn/projectname

And a trac project to go along with it

[root@repobox ~] trac-admin /var/www/trac/projectname initenv
[root@repobox ~] chown -R apache.apache /var/www/trac/projectname

Now lets add some security

[root@repobox ~] touch /etc/svn_trac-auth-conf
[root@repobox ~] htpasswd -m /etc/svn_trac-auth-conf username

Now trac has been setup, lets create a apache link to it:

[root@repobox ~] nano /etc/httpd/conf.d/trac.conf

Add the following:

        SetHandler mod_python
        PythonInterpreter main_interpreter
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnv /var/www/trac/projectname
        PythonOption TracUriRoot /trac/projectname

Now you can open trac on http://example.org/trac/projectname