phil has a blog - Setup Subversion and Trac for multiple projects

Setup Subversion and Trac for multiple projects

If you haven’t already its a good idea to enable SSL. For development purposes see: Create your own self signed certificate and enable SSL

1. Install Packages

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

2. Make directories to keep the repos and trac data in

sudo mkdir /srv/{svn,trac} -p

3. Create auth file with htpasswd with all users who will access svn and trac (note just -m for others)

sudo htpasswd -cm /etc/svn-auth-file username1
sudo htpasswd -m /etc/svn-auth-file username2

4. Create the access file to specify who can do what with each svn repository (r = read, w = write, or none) This explains it much better

sudo nano /etc/svn-access-file

e.g.

[groups]
developers = username1, username2

# for all projects allow all developers to read and write 
# and everyone else just read
[/]
@developers = rw
* = r

# username2 can read but not write to projectname1
[projectname1:/]
username2 = r

5. Setup site config and enable

sudo nano /etc/apache2/sites-available/www.example.org.conf

<VirtualHost *:443>
ServerName www.example.org

<Location /svn>
   # HTTP Proxy fix see http://phildawson.tumblr.com/post/50242370/
   # SetHandler               perl-script
   # PerlHeaderParserHandler  ProxyDav

   #
   DAV svn
   SVNParentPath /srv/svn

   # authentication
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile /etc/svn-auth-file
   Require valid-user

   # access
   AuthzSVNAccessFile /etc/svn-access-file
</Location>

<Location /trac>
   #
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /srv/trac
   PythonOption TracUriRoot /trac

   # authentication
   AuthType Basic
   AuthName "Trac"
   AuthUserFile /ewww.example.org

<Location /svn>
   # HTTP Proxy fix see http://phildawson.tumblr.com/post/50242370/
   # SetHandler               perl-script
   # PerlHeaderParserHandler  ProxyDav

   #
   DAV svn
   SVNParentPath /srv/svn

   # authentication
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile /etc/svn-auth-file
   Require valid-user

   # access
   AuthzSVNAccessFile /etc/svn-access-file
</Location>

<Location /trac>
   #
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /srv/trac
   PythonOption TracUriRoot /trac

   # authentication
   AuthType Basic
   AuthName "Trac"
   AuthUserFile /etc/svn-auth-file
   Require valid-user

   # access
   # use trac-admin
</Location>

</VirtualHost>

Enable and reload

sudo a2ensite www.example.org.conf
sudo /etc/init.d/apache2 reload

6. Create subversion repos and trac instance for each project

Create the svn repo

sudo svnadmin create /srv/svn/projectname1

Give Apache user ownership

sudo chown -R www-data:www-data /srv/svn/projectname1

Create the trac instance

sudo trac-admin /srv/trac/projectname1 initenv

Project name 1
<enter>
<enter>
/srv/svn/projectname1
<enter>

Fix for SSL redirect to http:// instead of https://

sudo nano /srv/trac/projectname1/conf/trac.ini
base_url = https://www.example.org/trac/projectname1/

Give Apache user ownership

sudo chown -R www-data:www-data /srv/trac/projectname1

Access by going to https://www.example.org/svn/projectname1/ and https://www.example.org/trac/projectname1/