For alternative installation methods have a look at the parent page: Trac

Before we start

A couple of remarks before we start:

PIP-based Installation

Although the stable version of Trac (0.12) was released in June 2010, Ubuntu Oneiric still ships with the (deprecated) 0.11 version of Trac. Therefore this tutorial will use Python's PIP installer tool.

Web-server Choice

Trac can run either on top of its own, standalone server (tracd) or on top of several generic web-servers, such as Apache, nginx, IIS etc. Even then, several plug-ins can be used on top of the web-server: Apache + FastCGI, Apache + mod_wsgi, Apache + mod_python, IIS + AJP, etc. This tutorial will use the Apache + mod_wsgi combination.

Database Choice

Trac defaults to SQLite for a database. PostgreSQL is also fully supported. MySQL is problematic, and the Trac Wiki states: supporting this database has proven to be painful at times. We recommend that you use it only if you don't have other choice. This tutorial will use SQLite for simplicity.

Authentication Methods

This tutorial uses Apache's basic authentication method (mod_auth_basic). However, it is recommended that you either enable SSL or at least use the "digest" authentication scheme instead of "Basic".

Version Control Systems

Trac is tightly integrated with the Subversion (SVN) VCS and defaults to that one out of the box. It's possible to use other VCSs through plug-ins. This tutorial will use the Mercurial (HG) VCS.

Installation Instructions

  1. First, install PIP:
    sudo apt-get install python-pip
  2. Install Trac using PIP:
    sudo pip install trac
  3. Initialize by typing:
    sudo trac-admin /opt/trac initenv

    (replace /opt/trac with the installation path of your choice). You will be asked for the project-name and the database connection.

  4. Install Apache2, mod_wsgi:
    sudo apt-get install apache2 libapache2-mod-wsgi
  5. Configure WSGI by running:
    sudo trac-admin /opt/trac deploy /opt/trac

    which will create a /opt/trac/cgi-bin/trac.wsgi file.

  6. Configure Apache by adding the following to /etc/apache2/sites-available/trac:

    WSGIScriptAlias /trac /opt/trac/cgi-bin/trac.wsgi
    <Directory /opt/trac>
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
  7. Give Apache the required privileges:
    sudo chown -R www-data /opt/trac
  8. Enable the "trac" site in Apache:
    sudo a2ensite trac
  9. Restart Apache:
    sudo service apache2 restart

Now point your browser to http://localhost/trac and you should see Trac's welcome screen

If you want to remove all the default wiki pages added during initenv, type:

sudo trac-admin /opt/trac wiki remove *

Configuring Authentication

  1. You can add the first user like this:
    sudo htpasswd -c /opt/trac/htpasswd firstuser
    (replace first-user with your user-name of choice), and the following users with
    sudo htpasswd /opt/trac/htpasswd nextuser
  2. Add the following to /etc/apache2/sites-available/trac:

    <Location "/trac/login">
        AuthType Basic
        AuthName "trac"
        AuthUserFile /opt/trac/htpasswd
        Require valid-user
    </Location>
  3. Remember to restart Apache:
    sudo service apache2 restart
  4. To grant administrator rights to a user, run:
    sudo trac-admin /opt/trac permission add username TRAC_ADMIN

Enabling Mercurial

For more details, read TracMercurial

  1. Install subversion if you haven't already done so:
    sudo apt-get install subversion
  2. Download the plugin's source code:
    svn co http://svn.edgewall.com/repos/trac/plugins/0.12/mercurial-plugin
  3. Build and install the "egg":
    cd mercurial-plugin && python setup.py bdist_egg && sudo python setup.py install
  4. Edit /opt/trac/conf/trac.ini:

    [components]
    tracext.hg.* = enabled
    
    [trac]
    repository_type = hg
    repository_dir = /path/to/my/hg/repository
  5. Restart Apache:
    sudo service apache2 restart

Syntax High-lighting

If you want syntax highlighting when browsing the source code, just install pygments:

sudo apt-get install python-pygments

and restart Apache.


TracApacheModWsgi (last edited 2011-11-20 21:13:29 by 78-105-201-166)