Electronox Blog Electronox Photo Gallery Electronox Forum

Source code repository with SVN and Trac on Debian Lenny April 30th, 2009 by Justin

 

There exist guides innumerable for this, but I recently went through this somewhat of a hassle and figured more documentation certainly wouldn’t hurt the situation. This is for a server located at trac.yourdomain.tld with multiple projects located in the the folders trac.yourdomain.tld/projectname1, trac.yourdomain.tld/projectname2.

Replace $projectnameX with your project’s name. Use the defaults for the trac-admin installer, except where it asks for your SVN Repository folder.

# apt-get install subversion libapache2-svn trac
# mkdir -p /var/local/svn/$projectname1
# mkdir -p /var/local/trac/$projectname1
# mkdir -p /var/local/svn/$projectname2
# mkdir -p /var/local/trac/$projectname2
# svnadmin create --fs-type fsfs /var/local/svn/$projectname1
# svnadmin create --fs-type fsfs /var/local/svn/$projectname2

# trac-admin /var/local/trac/$projectname1 initenv
# trac-admin /var/local/trac/$projectname2 initenv

# htpasswd -c /var/local/svn/$projectname1/conf/passwd $proj1username
# htpasswd -c /var/local/svn/$projectname2/conf/passwd $proj2username

//Additional users
# htpasswd /var/local/svn/$projectnameX/conf/passwd $addUser

Next, we need to configure Apache, this assumes you have SSL on port 443 configured. If not, you can just run over port 80 without the redirect.

Next, we need to configure Apache, this assumes you have SSL on port 443 configured. If not, you can just run over port 80 without the redirect.

# nano /etc/apache2/sites-enabled/trac.yourdomain.tld
<VirtualHost *:80>
        ServerName trac.yourdomain.tld
        Redirect permanent / https://trac.yourdomain.tld/
</VirtualHost>
<VirtualHost *:443>
        ServerName trac.yourdomain.tld
        DocumentRoot /var/local/trac
        SSLEngine On
        SSLCertificateFile /etc/apache2/apache.pem

        <Location />
                SetHandler mod_python
                PythonHandler trac.web.modpython_frontend
                PythonInterpreter main_interpreter
                PythonOption TracEnvParentDir /var/local/trac
                PythonOption TracUriRoot /
        </Location>

        <Location /$projectname1>
                AuthType Basic
                AuthName "trac.yourdomain.tld"
                AuthUserFile /var/local/svn/$projectname1/conf/passwd
                Require valid-user
        </Location>

        <Location /$projectname2>
                AuthType Basic
                AuthName "trac.yourdomain.tld"
                AuthUserFile /var/local/svn/$projectname2/conf/passwd
                Require valid-user
        </Location>

        CustomLog /var/log/apache2/trac.yourdomain.tld/access.log combined
        ErrorLog  /var/log/apache2/trac.yourdomain.tld/error.log
</VirtualHost>

# nano /etc/apache2/sites-enabled/svn.yourdomain.tld
<VirtualHost *:80>
        ServerName $projectname1.svn.yourdomain.tld
        Redirect permanent / https://projectname1.yourdomain.tld/
</VirtualHost>
<VirtualHost *:443>
        ServerName $projectname.svn.yourdomain.tld
        <Location /$projectname1>
                DAV svn
                AuthType Basic
                AuthName "SVN-DAV for $projectname1"
                AuthUserFile /var/local/svn/$projectname1/conf/passwd
                SVNPath /var/local/svn/$projectname1/
                Require valid-user
        </Location>

        <Location /$projectname2>
                DAV svn
                AuthType Basic
                AuthName "SVN-DAV for $projectname2"
                AuthUserFile /var/local/svn/$projectname2/conf/passwd
                SVNPath /var/local/svn/$projectname2/
                Require valid-user
        </Location>

        CustomLog /var/log/apache2/svn.yourdomain.tld/custom.log combined
        ErrorLog  /var/log/apache2/svn.yourdomain.tld/error.log
</VirtualHost>

Now we will add permissions to certain directories and create those error log directories so Apache will start up correctly — if it fails you probably haven’t created them!

# groupadd subversion
# addgroup $proj1username subversion
# addgroup $proj2username subversion

# chown -R www-data:subversion /var/local/svn/* /var/local/trac/*
# chmod -R 770 /var/local/svn/* /var/local/trac/*

# mkdir /var/log/apache2/svn.yourdomain.tld
# mkdir /var/log/apache2/trac.yourdomain.tld

If you want ssh+svn protocol access, you should add and designate users to your ssh daemon configuration file. While you are there make sure you have PermitRootLogin set to No to disable “root” from logging in remotely.

# adduser $proj1username
# adduser $proj2username

# nano /etc/ssh/sshd_config
# Authentication:
LoginGraceTime 20
PermitRootLogin no
StrictModes yes
AllowUsers YourRegularUsername $projusername1 $projusername2

Finally, restart your daemons, navigate to your pages, and checkout some source!

# /etc/init.d/apache2 restart
# /etc/init.d/ssh restart

Comment »

  1. Heartshare » Blog Archive » Debian lenny Setup Trac and Subversion

    [...] :  Source code repository with SVN and Trac on Debian LennyThere exist guides innumerable for this, but I recently went through this somewhat of a hassle and [...]

  2. June 11, 2009 @ 1:45 am

Leave a comment

updates