Friday, October 02, 2009

How to set up Trac + SVN on Ubuntu

sudo apt-get install trac
sudo apt-get install libapache2-mod-python libapache2-mod-python-doc libapache2-svn

# Create a directory where all your Trac projects will live
sudo mkdir /var/lib/trac
sudo mkdir /var/lib/svn

# Usernames
sudo htpasswd -cm /etc/svnauth urname
sudo htpasswd -cm /etc/svnauth nextuserrname

# Add following to /etc/svnaccess
sudo vim /etc/svnaccess
##################From here#########################

[groups]
developers = yourusername, nextusername
[ / ]
@developers = rw
* = r

##################Till here#########################

# Add following to /etc/apache2/sites-available/default
sudo vim /etc/apache2/sites-available/default
##################From here#########################



DAV svn
SVNParentPath /var/lib/svn

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/svnauth
Require valid-user

AuthzSVNAccessFile /etc/svnaccess




SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/lib/svn
PythonOption TracUriRoot /trac

AuthType Basic
AuthName "Trac"
AuthUserFile /etc/svnauth
Require valid-user



##################Till here#########################


# Statically set the users in envvars
sudo vim /etc/apache2/envvars
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

# Reload the configuration
sudo /etc/init.d/apache2 reload


# Say ur project name is PhDProject
sudo svnadmin create /var/lib/svn/PhDProject

# Assign permissions
sudo chown www-data:www-data -R /var/lib/trac
sudo chown www-data:www-data -R /var/lib/svn

# Create Trac with SVN
sudo trac-admin /var/lib/trac/PhDProject/ initenv 'PhDProject' 'sqlite:db/trac.db' 'svn' '/var/lib/svn/PhDProject'

# Add urself to developers group
sudo trac-admin /var/lib/trac/PhDProject/ permission add urusername developers

# Optional: Some cool plugin
sudo easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk

# Re-assign permission
sudo chown www-data:www-data -R /var/lib/trac
sudo chown www-data:www-data -R /var/lib/svn

# Reload the configuration and restart
sudo /etc/init.d/apache2 reload
sudo /etc/init.d/apache2 restart

References:
http://trac.edgewall.org/wiki/TracUbuntuMultipleProjects
http://anantgarg.com/2009/03/25/subversion-trac-multiple-projects/