Trac Installation on Debian Etch

The following sections describe the necessary steps to install and configure Trac on Debian Etch.

Trac is based upon python and needs one of the following databases

Optionally the following software could be used

  • subversion

  • Apache2

  • Other python tools like

    • setuptools
    • docutils
    • SilverCity and/or Enscript


Installing Apache2

If you didn't have done it before, you should

  1. Install the Apache2 webserver

  2. Install the Python module

  3. Restart the server

Command Summary

# apt-get install apache2
# apt-get install python-mysqldb
# apt-get install libapache2-mod-python
# a2enmod mod_python
# /etc/init.d/apache2 restart

Installing Database

Trac requires installation one of the following databases

Installing MySQL

For further information on MySQL, please refer to MySQL.

  1. Install the MySQL package.

  2. Install Python's MySQL interface.

  3. Create an MySQL Administration account, if not done before.

  4. Create a database named trac.

  5. Grant all access rights on the database trac to the local user trac.

Command Summary

# apt-get install mysql-server
# apt-get install python-mysqldb
# mysqladmin -u root password 'secret'
# mysqladmin -u root --password='secret' create trac
# mysql -u root --password='secret'
GRANT ALL PRIVILEGES ON trac.* TO trac@localhost IDENTIFIED by 'secret';
'Query OK, 0 rows affected'.
flush privileges;

Installing PostgreSQL

For further information on MySQL, please refer to PostgreSQL.

  1. Install the PostgreSQL package.

  2. Install Python's PostgreSQL interface.

  3. Change Administrator Password, if not done before.

  4. Create a user named trac.

  5. Create a database named trac.

  6. Grant all access rights on database trac to the local user trac.

# apt-get install postgresql-8.1
# apt-get install python-psycopg2
# su postgres -c "psql"
postgres=# ALTER USER postgres PASSWORD 'secret';
postgres=# CREATE USER trac PASSWORD 'secret';
postgres=# CREATE DATABASE trac OWNER trac;
postgres=# GRANT ALL ON DATABASE trac TO trac;
postgres=# \q

Installing SQLite

Installing SQLite on Debian Etch

Installing Subversion

For further information on Subversion, please refer to Subversion.

If you don't have installed subversion before, follow these steps to install subversion and create an initial subversion repository.

  1. Install the Subversion packages

As we like to use Subversion behind an Apache2 webserver, please

  1. Install the Apache2 Module for Subversion

  2. Create a Subversion Repository

  3. Follow Integrate Subversion into Apache2 Web Server carefully

Command Summary

# apt-get install subversion subversion-tools libapache2-svn
# svnadmin create /svn
# vi /etc/apache2/sites-available/www
# vi /etc/apache2/mods-available/dav_svn.conf

Installing setuptools

If you want to install Trac plugins later on, then you need to install Python's setuptools.

For detailed Information, please refer to the TracPlugins Wiki

# apt-get install python-setuptools

Installing docutils

Install the docutils, if you want to use an alternative Wiki Markup

# apt-get install python-docutils

Installing SilverCity and Enscript

These packages are used for Trac's syntax highlighting

The clearsilver package (python-clearsilver is already installed with the trac package.

If you are looking for Enscript, use this command.

# apt-get install enscript

Installing Trac

The following command installs trac, including subversion and basic python support

# apt-get install trac

If you followed the steps descibed above, the following command should install trac properly:

trac-admin /var/www/trac/trac-example initenv

The script will prompt you for the following questions

Enter your Trac Project Name (e.g. trac-example)

  • Database connection string [sqlite:db/trac.db]>

Select the one matching your database configuration, where user="johndoe", password="letmein", dbname="trac"

  • mysql://johndoe:letmein@localhost:3306/trac

  • postgres://johndoe:letmein@localhost/trac

  • sqlite:db/trac.db

    • Repository type [svn]>

Just press Enter

  • Path to repository [/path/to/repos]>

Enter e.g. _/svn/trac-example

  • Templates directory [/usr/share/trac/templates]>

Just press Enter

If all went well, then you should see something like this


A shortcut to create a new environment provides this command

# trac-admin /var/www/trac/trac-example initenv Promotion mysql://trac:secret@localhost:3306/trac  svn /svn/trac-example /usr/share/trac/templates

To grant administrator rigths on a trac project use the following command:

# trac-admin /var/www/trac/trac-example/ permission add "root" TRAC_ADMIN

Configuring Apache

We installed Trac to be used with Apache's Python Module.

With the following Location description, we configure Apache to serve Trac:

<Location /trac>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /var/www/trac/
   PythonOption TracUriRoot /trac

The option !TracEnvParentDir enables Trac to search for directories hosting Trac projects under the given path.

The option !TracEnv instruct Trac to use the Trac project under the given path only.

To support Authentication, you can use any of Apache's authentication mechanism. Adding the following lines to the trac location stated above, you can enable SSL Client Authentication for your Trac projects. Trac will use the user name provided within the SSLUserName variable, which will be transmitted to the REMOTE_USER environment variable.

<Location /trac>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /var/www/trac/
   PythonOption TracUriRoot /trac

   SSLOptions +ExportCertData
   SSLVerifyClient require
   SSLVerifyDepth 2
   SSLRequire %{SSL_CLIENT_S_DN_CN} in {"Peter Miller", "Claus Burger"}


Multiple Projects in Trac

In order to host multiple project on one Trac instance, you need to setup one database for each Project.

Updated by Lutz Suhrbier about 14 years ago ยท 36 revisions