Trac on Ubuntu
Help wanted: The various Ubuntu specific install docs should be cleaned and merged where that makes sense…
- Back to TracInstallPlatforms
- TracInstall - See this before reading any distro specific tutorial
Note: It is always best practice to use the latest stable version of Trac.
| tutorial | Ubuntu Version | Trac Version | Apache | VCS | Database |
|---|---|---|---|---|---|
| Ubuntu-11.10 | 11.10 | 0.12 | Mod_WSGI | ? | ? |
| Ubuntu-10.04-Subversion | 10.04 | 0.12 | Mod_Python | Subversion | MySQL |
| 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 |
| ubuntu Help | ? | ? | Mod_Python | ? | SQLite |
| 0.11/TracOnUbuntu | 8.04 | 0.11 | Mod_Python | Subversion | SQLite |
| hardy, cgi | 8.04 | 0.11 | | Subversion | SQLite |
| TracUbuntuMultipleProjects | 8.04 | 0.11 | Mod_Python | Subversion | SQLite |
| 0.10.4/TracOnUbuntuHardy | 8.04 | 0.10.4 | Mod_Python | Subversion | SQLite |
| TracFeisty | 7.04 | ? | Mod_Python | Subversion | SQLite |
| TracInstallUbuntu | ? | 0.11.5 | Mod_Python | ? | SQLite |
| Ubuntu-Trac | ? | ? | Mod_Python | Subversion | SQLite |
| Ubuntu 5.10 "The Breezy Badger" | 5.10 | ? | Mod_Python | Subversion | SQLite |
| Ubuntu 5.10 with workingenv | 5.10 | ? | Fast_CGI | ? | SQLite |
DB: Most tutorials do not say the database they are using. I assume the default is SQLite.
Ubuntu 8.04.2 Hardy Note: the default package installs trac-post-commit-hook under /usr/share/doc/trac/contrib path. Unfortunately this script is not working correctly with Trac 0.11 and you need to download the latest version from 0.11-stable/contrib/trac-post-commit-hook.
Installing Trac on Ubuntu
This is a short recipe to install and configure virtual Apache2 host with Trac
Which Ubuntu packages are needed
Typical procedure to install Trac under Ubuntu with its default dependencies (default - choosed by apt) is
apt-get install python python-babel apt-get install trac
Ensure that python version matches Trac latest, otherwise apt will install older Trac version which matches your old python package installed. Also take into account that python-babel should be always installed before trac if you wish to see it internationalized.
Upgrade python packages
Ubuntu pre-packaged python resources are not always newest, and 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 virtual host
Here is shown sample virtual host configuration running under apache2 (one file) with minimal, "entry level" settings. Config file created at apache2 known place for site configs (see below), and then configured site can be "enabled" to run.
The following considerations used within this config, yours may vary, so adjust them below appropriately at your own
- 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 ident
Prepare configuration
First you need to
- create directory for 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
Enter the following copy-paste 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 TracEnv /var/local/trac # 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 service apache2 restart


