Edgewall Software

Version 3 (modified by ThurnerRupert, 16 years ago) ( diff )

Trac on Ubuntu

These instructions were tested with a fresh install of 8.04, and installs trac-0.11-rc1.

Also see TracOnUbuntu, Ubuntu-Trac.

Installation

1. Install Software Packages

To install Trac on your system, install the trac, libapache2-mod-python, libapache2-svn, and python-setuptools packages:

sudo apt-get install apache2 libapache2-mod-python libapache2-svn python-setuptools
sudo easy_install Trac==0.11rc1

2. Create the Trac Environments Directory

You'll need a directory for Trac's environments to live that should be writable by the default Apache user:

sudo mkdir /var/lib/trac
sudo chown www-data:www-data /var/lib/trac

3. Setup Apache2

Next, create a new Apache-2 virtualhost, and paste the text below into the file:

sudo vi /etc/apache2/sites-available/trac
<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName trac.example.com
        DocumentRoot /var/www

        <location /projects>
                SetHandler mod_python
                PythonInterpreter main_interpreter
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnvParentDir /var/lib/trac
                PythonOption TracUriRoot /

                ErrorLog /var/log/apache2/error.trac.log
                CustomLog /var/log/apache2/access.trac.log combined
        </location>

        # use the following for one authorization for all projects                      
        <LocationMatch "/projects/[[:alnum:]]+/login">             
            AuthType Basic                                                              
            AuthName "trac"                                                             
            AuthUserFile /etc/apache2/dav_svn.passwd
            Require valid-user                                                          
        </LocationMatch>          

</VirtualHost>

Now, disable the default virtualhost, enable the Trac virtualhost, and restart Apache2:

sudo a2dissite default
sudo a2ensite trac
sudo  /etc/init.d/apache2 reload 

4. Creating Environments

I installed my Subversion repository at /var/lib/svn/YourProjectNameHere. So I did a quick starting config of subversion with the following commands:

sudo svnadmin create /var/lib/svn/YourProjectNameHere

Some permissions changes and an apache restart are now needed:

sudo chown -R www-data /var/lib/svn
sudo chown -R www-data /usr/share/trac
sudo apache2 -k restart

I put my trac environment at /var/lib/trac/YourProjectNameHere. Of course you could use any other path or name - something a little more descriptive of your project would probably be a good idea. First I ran these commands:

sudo mkdir /var/lib/trac
sudo trac-admin /var/lib/trac/YourProjectNameHere initenv
sudo chown -R www-data /var/lib/trac

The "trac-admin" command shown above prompted me to enter:

  • the project name (YourProjectNameHere)
  • the path to svn repository (/var/lib/svn/YourProjectNameHere)

… then it prints out a bunch of stuff. If there are no errors you should now be able to surf to your Trac site at http://servername/

For more complex mod_python configs, see TracModPython

make subversion running as well

You will also need to uncomment the settings in /etc/apache2/mods-available/dav_svn.conf

<Location>
    # Uncomment this to enable the repository,
    DAV svn

    # Set this to the path to your repository
    SVNParentPath /var/lib/svn
</Location>
Note: See TracWiki for help on using the wiki.