Edgewall Software

Trac on Ubuntu

Help wanted: The various Ubuntu specific installation documents should be cleaned and merged where that makes sense.

Note: It is always best practice to use the latest stable version of Trac.

Tutorial Ubuntu Version Trac Version Apache VCS Database
Ubuntu 16.04 16.04(10) 1.2.2 x git/pypy SQLite
Ubuntu-14.04 14.04 0.12 Mod_Python Subversion MySQL
Ubuntu-11.10 11.10 0.12 Mod_WSGI ? SQLite
Ubuntu-10.04-Bazaar 10.04 0.12 Mod_WSGI Bazaar MySQL
Ubuntu-10.04.03-Git 10.04.03 0.11 Mod_Python Git MySQL
0.11/TracOnUbuntu 8.04 0.11 Mod_Python Subversion SQLite
TracInstallUbuntu 8.04 0.11.5 Mod_Python ? SQLite
TracUbuntuMultipleProjects 8.04 0.11 Mod_Python Subversion SQLite
TracFeisty 7.04 ? Mod_Python Subversion SQLite
Ubuntu-Trac ? ? Mod_Python Subversion SQLite
Ubuntu Help ? ? Mod_Python ? SQLite

Database: Most tutorials do not state the database they are using. The default database is SQLite.

Installing Trac on Ubuntu

This is a short recipe to install and configure a virtual Apache2 host with Trac.

Which Ubuntu packages are needed

The typical procedure to install Trac under Ubuntu with its default dependencies (default - chosen by apt) is:

apt-get install python python-babel
apt-get install trac

Ensure that the Python version matches the Trac latest, otherwise apt will install a Trac version which matches the older version of Python that you have installed. Also take into account that python-babel should be always installed before trac, if you wish to later configure internationalisation.

Upgrade Python packages

Ubuntu pre-packaged Python resources are not always the newest; you may consider to upgrade them with easy_install or pip.

  • Upgrade with easy_install:
    easy_install Babel
    easy_install Trac
    
  • Upgrade with pip (another Python installer, namely python-pip):
    apt-get install python-pip
    pip install --upgrade Babel
    pip install --upgrade Trac
    

Configuring a virtual host

Here is a sample virtual host configuration running under apache2 (one file) with minimal, entry-level settings. The configuration file should be created at the apache2 known place for site configs (see below), and then the configured site can be "enabled" to run.

The following considerations used within this configuration. Yours may vary, so adjust them below accordingly:

  • trac.local is a hostname of virtual host
  • /var/local/trac is a directory (Trac project) at that host
  • /var/local/trac/.htpasswd is a password file created with htpasswd utility
  • ru_RU.UTF8 is a locale identifier

Prepare configuration

First you need to:

  • create a directory for the Trac project and change its access permissions to that under which apache2 runs (www-data in most cases)
  • initialize Trac environment within that directory
  • create apache2 htpasswd entry for authorized web user access within this directory
  • add to Trac this authorized web user with administrative privileges over Trac:
    mkdir -p /var/local/trac
    trac-admin /var/local/trac initenv
    htpasswd -c /var/local/trac/.htpasswd adminusername
    trac-admin /var/local/trac permission add adminusername TRAC_ADMIN
    chown -R www-data: /var/local/trac
    chmod -R 775 /var/local/trac 
    

Create config file with any text editor (vi in this example):

vi /etc/apache2/sites-available/trac.conf

Enter the following into this file:

<VirtualHost *:80>
        ServerName trac.local
        <Location />
           SetHandler mod_python
           PythonInterpreter main_interpreter
           PythonHandler trac.web.modpython_frontend
           PythonOption TracEnv /var/local/trac
           PythonOption TracEnvParentDir /var/local/trac
           PythonOption TracUriRoot /
           # PythonOption TracEnvIndexTemplate /var/local/trac/templates/index-template.html
           PythonOption TracLocale en_US.UTF8
           PythonOption PYTHON_EGG_CACHE /tmp
           Order allow,deny
           Allow from all
        </Location>
        <Location /login>
          AuthType Basic
          AuthName "myproject"
          AuthUserFile /var/local/trac/.htpasswd
          Require valid-user
        </Location>
</VirtualHost>

Enable prepared configuration

sudo apt-get install libapache2-mod-python
a2enmod python
a2ensite trac.conf
service apache2 restart
Last modified 6 years ago Last modified on Mar 28, 2019, 12:09:39 PM
Note: See TracWiki for help on using the wiki.