As part of a group project I’ll be doing over the next few terms, I had to set up a few utilities - trac, mediawiki, and reviewboard. It took me a while to figure out how to install these properly on a shared server - none of the tutorials I saw were entirely correct - so I figured that I should write my own.
Trac is a issue-tracker system that integrates with your version control system so you can track bugs by commits. I haven’t used it extensively yet - I’ll probably do another post on usage once I’ve been using it more. The first thing you need to do to install trac is to install all the required packages. On Ubuntu, you can do this with:
sudo apt-get install apache2 libapache2-mod-python libapache2-svn python-setuptools subversion python-subversion
Next, you need to create a base ‘trac’ directory somewhere on your filesystem and allow the apache user www-data to be able to read and write to it. If you want it to be in /home/trac, for example, you can do the following:
sudo mkdir /home/trac sudo chown www-data:www-data /home/trac
Now, to create an individual trac project you need to know two things; 1) the name of you project, which is your choice, and 2) the location of your source control repository. Trac supports several different source control systems; we’re using it with subversion. Answer all the questions it asks you and your project will be created.
Next, you need to create the apache configuration file for this. Assuming that you want trac to be accessed by trac.somedomain.com, create the file /etc/apache2/sites-available/trac.somedomain.com from the following template, changing the values in []:
ServerAdmin [yourEmail] ServerName [trac.yourDomain.com] ErrorLog [errorLogFile] CustomLog [logFile] combined # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn ServerSignature On SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir [tracParentDirectory (e.g /home/trac)] PythonOption TracUriRoot / PythonOption PYTHON_EGG_CACHE /tmp # use the following for one authorization for all projects # (names containing "-" are not detected):AuthType Basic AuthName "trac" AuthUserFile /var/svn/conf/svnusers Require valid-user
This requires users to be authenticated to access trac.yourdomain.com. To create an authentication file, you need to do the following:
cd /var/svn/conf/ htpasswd svnusers [username] [newpass] htpasswd svnusers [username2] [newpass2]
Repeat this for all the users you wish to be able to authenticate. You also need to define a policy file in /var/svn/conf/svnpolicy. This file has the following format:
[project1:path] user1 = rw user2 = r usrer3 = rw [project2:path] user1 = rw user2 = rw user3 = brw
The project name will be the name of your trac project; the path is probably /, unless you want some parts of your trac setup to be authenticated differently than others. This should set up the authentication fro trac.
After this, you need to symlink the file your created in sites-available to sites-enabled and reload and restart apache:
cd /etc/apache2/sites-enabled ln -s ../sites-available/trac.yourdomain.com . /etc/init.d/apache2 reload /etc/init.d/apache2 restart
After this, the site should be accessible if you edit your hosts file to redirect to it by adding the following line to /etc/hosts:
[siteip] trac.yourdomain.com
However, you probably want to be able to access it from any computer without modifying your hosts file. To do this, you need to go into whatever DNS manager you use and add an entry for trac.yourdomain.com that points to your server.
This ended up being longer than I expected, so I’ll cover mediawiki and reviewboard in later posts. Let me know if anything here is incorrect or more should be covered.
Tags: trac