Category: Web applications

  • Setting up svn with trac

    Trac is an excellent web-based wrapper for SVN that adds bug tracking, a wiki, and several handy project management features. I keep setting up new repositories up for all the little projects we cook up in DB2 Technical Marketing, so I thought I’d write up a guide.

    Installing Trac, SVN, and dav_svn for Apache2 is left as an exercise for the reader.

    Create a new SVN repository:

    svnadmin create /var/svn/Project
    

    Create a new Trac environment:

    trac-admin /var/trac/Project initenv
    

    Change the owner to Apache so that it can read and write:

    cd /var/svn
    chown -R www-data Project
    cd ../trac
    chown -R www-data Project
    

    Navigate to Apache site settings:

    cd /etc/apache2/sites-enabled
    

    If you want Trac to support multiple repositories, edit the trac file to look like this:

    
            ServerAdmin me@somewhere.com
            ServerName mysite.com
            DocumentRoot /usr/share/trac/cgi-bin/
            
                    Options Indexes FollowSymLinks MultiViews ExecCGI
                    AllowOverride All
                    Order allow,deny
                    allow from all
            
            Alias /var/trac/chrome/common /usr/share/trac/htdocs
            
                    Order allow,deny
                    Allow from all
            
            Alias /trac "/usr/share/trac/htdocs"
    
            
                    SetEnv TRAC_ENV_PARENT_DIR "/var/trac"
            
            
                    AuthType Basic
                    AuthName "Trac"
                    AuthUserFile /etc/apache2/trac.passwd
                    Require valid-user
            
    
            DirectoryIndex trac.cgi
            ErrorLog /var/log/apache2/error.trac.log
            CustomLog /var/log/apache2/access.trac.log combined
    
    

    The above assumes that all the repositories are in /var/trac

    Navigate to Apache settings:

    cd /etc/apache2/mods-enabled/
    

    Append to dav_svn.conf:

    
       DAV svn
       SVNPath /var/svn/Project
    
       AuthType Basic
       AuthName "Subversion Repository"
       AuthUserFile /etc/apache2/dav_svn.passwd
    
      AuthzSVNAccessFile /etc/apache2/dav_svn.authz
    
      
        Require valid-user
      
    
    
    

    The above lets you check out from http://yoursite/svn/Project

    If you like, you can add a new user to dav_svn.psswd:

    cd ..
    htpasswd2 /etc/apache2/dav_svn.passwd NewUser
    

    Users can then be granted permissions by editing the dav_svn.authz file. Sample file:

    [groups]
    developers = NewUser, OtherUser
    others = ThirdUser
    
    # Restrictions on the entire repository.
    [/]
    # Anyone can read.
    * = r
    # Developers can change anything.
    @developers = rw
    
    # Other can write here
    [/trunk/public/images]
    @others = rw
    
    [/trunk/public/stylesheets]
    @others = rw
    

    Restart Apache:

    killall apache2
    apache2
    

    You now have have an Trac/SVN install with SVN at http://yoursite/svn/Project and Trac at http://yoursite/trac.cgi