Juancho Fonseca

Riohachu's Dashboard

14
May 2010

Fast Trac setup in Debian

This is it, a fast deploy of Trac with Debian step by step.

I used Debian lenny (Stable) version because in Squeeze some packages are different from the stable version. In this guide the instance is called test you can change the name to whatever you want. Root user

First of all install Trac from the packages repository:

apt-get install trac

Additional packages:

apt-get install subversion-tools trac-spamfilter python-dev python-psycopg2 libapache2-mod-wsgi libapache2-mod-fcgid libapache2-mod-python libapache2-svn svnmailer

SVN setup

Create a user for SVN:

addgroup svn

adduser svn --no-create-home --system --ingroup svn

Prepare directory:

mkdir /var/svn

svnadmin create /var/svn/test

chown -R www-data:www-data /var/svn/test

To create the instance run:

trac-admin /var/www/test initenv

This is the output of the command, in Bold what you have to change:

Creating a new Trac environment at /var/www/test

Trac will first ask a few questions about your environment 

in order to initialize and prepare the project database.

 Please enter the name of your project.

 This name will be used in page titles and descriptions.

Project Name [My Project]> Test Trac

 Please specify the connection string for the database to use.

 By default, a local SQLite database is created in the environment

 directory. It is also possible to use an already existing

 PostgreSQL database (check the Trac documentation for the exact

 connection string syntax).

I used an external server with PostgreSQL to host the trac database, but you can leave this with the default option SQLite if you want your trac database to be in the same server.

Database connection string [sqlite:db/trac.db]> postgres://user:password@server:5432/tracdb?schema=tracsch

 Please specify the type of version control system,

 By default, it will be svn.

 If you don't want to use Trac with version control integration,

 choose the default here and don't specify a repository directory.

 in the next question.

Repository type [svn]> svn

 Please specify the absolute path to the version control

 repository, or leave it blank to use Trac without a repository.

 You can also set the repository location later.

Path to repository [/path/to/repos]> /var/svn/test


Create administrator user:

trac-admin /var/www/test

Welcome to trac-admin 0.11.1

Interactive Trac administration console.

Copyright (c) 2003-2008 Edgewall Software

Type:  '?' or 'help' for help on commands.        

Trac [/var/www/teat]> permission add administratorname TRAC_ADMIN

APACHE

I used SSL and the trac website is located in the root level of apache

Generate *gi Scripts used by the web server with this command:

trac-admin /var/www/test deploy /var/www/scripts

Create the htpasswd file using the program of the same name:

cd /var/www/test

htpasswd -c trac.htpasswd USERNAME

Activate required modules in Apache:

a2enmod ssl

Create an Apache Virtual host File with this config:

WSGI VIRTUAL HOST

<IfModule mod_ssl.c>

<VirtualHost *:443>

        PythonInterpreter main

PythonDebug on

ServerAdmin test@test.com

ServerName test

        DocumentRoot /var/www/scripts/htdocs 

<Directory /var/www/test>

                Order allow,deny

                Allow from all

        </Directory>

 

        ErrorLog /var/log/apache2/test-error.log

        LogLevel warn

        CustomLog /var/log/apache2/sysadm-access.log combined

 

SSLEngine on

        SSLCertificateFile /etc/ssl/location.of.your.crt

        SSLCertificateKeyFile /etc/ssl/location.of.your.key

 

WSGIScriptAlias / /var/www/scripts/cgi-bin/trac.wsgi

<Location />

WSGIApplicationGroup %

SetHandler mod_python

PythonHandler trac.web.modpython_frontend

                PythonOption TracEnv /var/www/test

PythonOption PYTHON_EGG_CACHE /tmp

                PythonOption TracUriRoot /

Order deny,allow

Allow from all

</Location>

 

<Location /login>

       AuthType Basic

      AuthName "Trac Login"

         AuthUserFile /var/www/test/trac.htpasswd

         Require valid-user

        </Location>

 

# ------ SUBVERSION ----

        <Location /svn/test>

                DAV svn

                SVNPath /var/svn/test

                # how to authenticate a user

                AuthType Basic

                AuthName "Subversion repository"

                AuthUserFile /var/www/test/trac.htpasswd

                AuthzSVNAccessFile /var/svn/test/conf/authz

                # For any operations other than these, require an authenticated user.

                <LimitExcept GET PROPFIND OPTIONS REPORT>

                        Require valid-user

                </LimitExcept>

        </Location>

</VirtualHost>

Enable VirtualHost, and enable web server configuration

cd /etc/apache2/sites-enabled

ln -s ../sites-available/test.ssl test.ssl

chown -R www-data:www-data /var/www

/etc/init.d/apache2 restart

And it's done, i use these steps to get a Trac web up and running. Hope it works for you too!