Edgewall Software

Version 47 (modified by Alexey Shamrin <shamrin@…>, 15 years ago) ( diff )

Changed nim to project and fixed chown (mustbe chown user file)

Installing and Running Trac on Debian

The Debian Sid distribution already contain Trac and all required dependencies. Debian Woody and Sarge users need to add a few lines to their /etc/apt/sources.list before installing Trac.

For Woody:

# Trac, clearsilver, sqlite, pysqlite
deb http://ftp.edgewall.com/pub/debian woody trac
# Subversion, Apache2
deb http://people.debian.org/~adconrad woody subversion

For Sarge:

# Trac and clearsilver
deb http://ftp.edgewall.com/pub/debian sarge trac


 $ apt-get update

after editing the file to update the package cache.

Installing Trac and the required dependencies should now be as simple as:

 $ apt-get install trac

Note: While installing Trac on Debian Woody you might get some harmless warnings when the installation process byte-compiles some source files.

More notes for Trac 0.8 on Debian Woody:

Notice, this is what worked for me on a new Woody system I built just to host Trac (in a VMware image, yet!), so I was able to be a little free with modifications I made. Be more careful if you are adding Trac to a system you use for other tasks - don't blame me if these instructions break something!

These instructions ignore the above and start at the very beginning.

  • Subversion really wants Apache2 installed. If you run apache2 -v and get an error, you'll need to install Apache2. I removed apache 1.3 and installed Apache2 with the following:
    apt-get install apache2-common apache2-doc apache2-mpm-worker libapache2-svn
    apt-get remove apache
    apache2 -k start
    Also, edit /etc/default/apache2 so it says NO_START=0 if you want apache2 to run on boot.
  • Trac 0.8 runs better with Python 2.2 and python-xml (without them, diffs and attachment uploading will not work). Note that Trac's email notifications will not work unless you have Python 2.2.2 or greater. Since I couldn't find a Debian/stable .deb for anything higher than Python 2.2.1, I gave up on email notifications. Everything else seems to be workng though!
    apt-get install python2.2-xmlbase python2.2-sqlite
    cd /usr/bin
    mv python python.orig
    ln -s python2.2 python
    cp -R /usr/lib/python2.1/site-packages /usr/lib/python2.2
    apache2 -k restart
  • After completing these pre-requisites, I added the following to /etc/apt/sources.list
    deb http://ftp.edgewall.com/pub/debian woody trac
    deb http://people.debian.org/~adconrad woody subversion
    and ran
    apt-get install trac 
  • Getting Subversion working:

I decided to keep my Subversion project at /var/svn/project. Here are the commands I entered to get SVN up and running:

mkdir /var/svn
mkdir /var/svn/project
mkdir /tmp/project
mkdir /tmp/project/branches
mkdir /tmp/project/tags
mkdir /tmp/project/trunk
svnadmin create /var/svn/project
svn import /tmp/project file:///var/svn/project -m "initial import"
rm -rf /tmp/project

I added the following to /etc/apache2/sites-available/default:

#SVN dir
<Location /svn>
  DAV svn
  SVNParentPath /var/svn

Then I fixed permissions and restarted apache2:

chown www-data /var/svn/project
chown -R www-data /var/svn/project/*
apache2 -k restart

I was able to test by going to http://servername.foo.com/svn/project where I could see the empty directories as imported. I did not move on to the next step until this worked right!

  • Getting Trac running:

I put my trac environment at /var/trac/project. I'm not using the mod_python extentions at the moment. First I ran

trac-admin /var/trac/project initenv 

The command above prompted me to enter the project name, the path to the trac environment, and the path to the Trac templates directory; then it printed out a bunch of stuff.

Next, I edited /etc/apache2/sites-available/default. I commented out the existing ScriptAlias and <Directory "/usr/lib/cgi-bin"> directives, and added this at the end:

Alias /trac "/usr/share/trac/htdocs"
ScriptAlias /cgi-bin/ /usr/share/trac/cgi-bin/
<Location "/cgi-bin/trac.cgi">
 SetEnv TRAC_ENV "/var/trac/project"
<Directory "/usr/share/trac/htdocs">
  Options Indexes MultiViews
  AllowOverride None
  Order allow,deny
  Allow from all
# You need something like this to authenticate users
<Location "/cgi-bin/trac.cgi/login">
  AuthType Basic
  AuthName "project"
  AuthUserFile /var/www/trac.htpasswd
  Require valid-user

Now to fix the permissions, add a couple of users, and restart Apache:

cd /var/www
htpasswd -c trac.htpasswd user1     (you'll be prompted for the password)
htpasswd trac.htpasswd bar user2    (you'll be prompted for the password)
apache2 -k restart

Finally, test by going to http://servername.foo.com/cgi-bin/trac.cgi

On my installation, I do get some errors ("Python C API version mismatch for module blah") when I run trac-admin at the commandline. Apache also logs similar errors. This is probably because I didn't upgrade to Python2.2 until after I installed Trac. Hopefully these errors will be avoided by upgradng Python first (as I have advised above), but in any case they don't seem to hurt Trac at all. Everything (except email notifications which I don't need anyway) works perfectly!

Furthermore, there is a guide on building the Debian Trac package from the trunk at TracOnDebianFromTrunk

Note: See TracWiki for help on using the wiki.