A quick recipe to install Trac with the GitPlugin on Ubuntu 8.10 using Apache mod_python.
After considerable searching and more searching I found a README file with instructions specifically for the trac-git package. It is located at /usr/share/doc/trac-git/README.Debian and is installed with the trac-git package.
This recipe will cover steps to install Trac based on the instructions from the official install guide with the modifications described in README.Debian.
Package Installation
Install the following packages with your favorite apt front-end:
- apache2
- libapache2-mod-python
- git-core
- trac
- trac-git
Or you can run the following command:
$ sudo apt-get install apache2 libapache2-mod-python git-core trac trac-git
Setup the Git Repository
Setup your bare git repository. I’ll summarize this step, but more information can be found at the manual page for git-init.
$ git init --bare /var/git/my-app.git
Setup Trac
For consistency with default install paths and those paths used on the Trac website, I’ll be using the same paths in all the examples below. Trac installations are stored in /var/lib/trac/ and git repositories are stored in /var/git/.
The next step is to initialize the Trac environment using trac-admin. This is accomplished via the following single command:
$ trac-admin /var/lib/trac/my-app initenv "My Application" sqlite:db/trac.db git /var/git/my-app.git
See the TracAdmin article for more information about the trac-admin command.
At this point you may notice an odd warning in the output of trac-admin:
Warning:
Repository type git not supported
The warning is announced because the git plug-in has not been initialized, so Trac is unaware of “git” repositories. Our next steps are to configure Trac to use the GitPlugin.
Trac Configuration for GitPlugin
Note: These instructions vary from those described in the official GitPlugin configuration. They are specifically for the Debian based package (or Ubuntu in our case). See /usr/share/doc/trac-git/README.Debian for specifics.
We begin by editing conf/trac.ini which, in our example, is located at /var/lib/trac/my-app/conf/trac.ini.
Add the following to the bottom of the file to enable GitPlugin:
[components] gitplugin.* = enabled
Then check that the following git configurations are set properly, specifically verify that git_bin is using an absolute path.
[git] cached_repository = false # git_bin must be set to git's absolute path # or it will not work, "git" is not sufficient git_bin = /usr/bin/git persistent_cache = false shortrev_len = 6
That’s all for the Trac configuration. Next we’ll be configuring Apache.
Apache Configuration
Ensure mod_python is enabled:
$ sudo a2enmod mod_python
Now create a new file /etc/apache2/sites-available/trac-my-app. Use a suitable file name that matches your apache configurations.
# Trac Apache config for My App
# /etc/apache2/sites-available/trac-my-app
<VirtualHost *>
ServerName my-app.my-server
DocumentRoot /var/lib/trac/my-app/htdocs
<Location />
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /var/lib/trac/my-app
PythonOption TracUriRoot /
PythonOption PYTHON_EGG_CACHE /tmp
</Location>
ErrorLog /var/log/apache2/error.my-app.trac.log
CustomLog /var/log/apache2/access.my-app.trac.log combined
</VirtualHost>
Enable this apache configuration then reload the apache configurations:
sudo a2ensite trac-my-app sudo /etc/init.d/apache2 reload
Success!
Your Trac instance should now be setup with GitPlugin! Try visiting http://my-app.my-server in your browser to interact with your new setup.