How to install and configure Trac on Debian GNU/Linux to track your software development

Friday, 20th August 2010

1. Install trac debian package

debian:~# apt-get install trac

2. Create trac project directories in /var/www/

debian:~# mkdir /var/www/trac
debian:~# mkdir /var/www/trac/project
...

If you have more than one repositories in Subversion then add as many /var/www/trac/project1, /var/www/trac/project2 as you like.
3. Initialize the base environment for a new track project and set proper permissions

debian:~# trac-admin /var/www/trac/project initenv
debian:~# find /var/www/trac/project -type f -exec chmod 660 {} ;

debian:~# find /var/www/trac/project -type d -exec chmod 2770 {} ;

When you type the trac-admin command you will have to fill in some very basic data concerning the new track project.

You will be prompted for things like project name , project sql type ,
repository type etc.
The most vital thing to enter here is the repository type and path to your repository.
Thanksfully by default trac uses svn so you just press enter when you’re prompted for repo type.

Afterwards you will have to fill in the path to your svn repository in my case it was
/var/svn-repos/project

4. Deploy the track cgi scripts with trac-admin

debian~:# trac-admin /var/www/trac/project /tmp/deploy
debian:~# mv /tmp/deploy/* /var/www/trac
debian:~# rm -rf /tmp/deploy

5. Install trac-spamfilter package to prevent spam on your Trac tickets

debian:~# apt-get install trac-spamfilter

6. Install support for MySQL as a default Trac data storage
If you’re about to go with MySQL in favour of the default sqlite, (though I personally choose not to use it) issue command:

debian:~# apt-get install python-mysqldb

Edit and add to your /etc/apache2/sites-available/default the following variables:
Alias /trac "/usr/share/trac/htdocs"
ScriptAlias /trac/project /usr/share/trac/cgi-bin/trac.cgi
<Location "/trac/project">
SetEnv TRAC_ENV "/var/www/trac/project"
</Location>

It’s a good idea also to add authentication to your trac to prevent any unwanted visitors to download your project source.

Again in your /etc/apache2/sites-enabled/default add something similar to:

<Location "/trac">
AuthType Basic
AuthName "Trac project"
AuthUserFile /etc/apache2/trac.htpasswd

Require valid-user
</Location>

7. Edit your /var/www/trac/project/conf/trac.ini

Some of the values I changed here and you might find it handy as well are:

By default attachment max_size was pretty low max_size = 262144 I decided to incrase it to max_size = 2621440

I’ve also changed src = site/logo.png to the exact path of my project logo. Changing this will make your project logo appear in the head of your new trac installment.

Something else I changed was the footer var which by default had a link pointing to trac’s webpage I changed it to point to my project website, so you might consider doing same too.
I believe this is all I did to have a running installation of trac.
Few things to mention is that this installation uses the slower trac.cgi instead of the way faster and recommended trac.fcgi, however lest my many attempts to make the trac.fcgi as explained in Trac Guide I did not succeeded in starting apache to serve trac via trac.fcgi script.

It’s really odd that the default steps explained in Trac On Debian as followed literally as described in the documnetation wouldn’t get you anywhere and you will end up with an installation that is not really working, for some strange reason the documentation misses the trac cgi deploy step as I explain in above.

We also need to create the /etc/apache2/trac.htpasswd .htaccess file. To do so issue:

debian:~# htpasswd -c /etc/apache2/trac.htpasswd passwd
password:

Place your password of choice
Be sure to also comment any existing declarations that say something like:

ScriptAlias
or
<Directory "/usr/lib/cgi-bin">

Any user feedback is very welcome, any suggestions or problems with the described install are about to be fixed asap as I have a user feedback.

Share this on:

Download PDFDownload PDF

Tags:

2 Responses to “How to install and configure Trac on Debian GNU/Linux to track your software development”

  1. Janeth Spuhler says:
    Firefox 3.5.3 Firefox 3.5.3 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3

    Great points on computers. Excited to have discovered your blog and add it to my reader. Cheers!

    View CommentView Comment

Leave a Reply

CommentLuv badge