Edgewall Software

Version 22 (modified by anonymous, 19 years ago) ( diff )

oops

Trac on Ubuntu

These instructions were written for a fresh install of Ubuntu. This documentation suggests performing custom install when installing Ubuntu to create a base system without an X server or other graphical niceties. These instructions, however, should work reasonably well if you already have Ubuntu installed or you have performed a full install.

Warty users: Ubuntu needs versions of python-sqlite and clearsilver that aren't available on Warty (see #468 & #1104). You will need to upgrade to the Hoary release or later.

Installation

1. Install Software Packages

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

sudo apt-get install trac libapache2-svn

2. Create the Trac Envioronments Directory

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

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

3. Setup Apache2

Next, create a new Apache-2 virtualhost by saving the following as /etc/apache2/sites-available/trac :

<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName trac.example.com
        DocumentRoot /usr/share/trac/cgi-bin/
        <Directory /usr/share/trac/cgi-bin/>
                Options Indexes FollowSymLinks MultiViews ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        Alias /trac "/usr/share/trac/htdocs"

        <Location /trac.cgi>
            SetEnv TRAC_ENV "/var/trac"
        </Location>

        DirectoryIndex trac.cgi
        ErrorLog /var/log/apache2/error.trac.log
        CustomLog /var/log/apache2/access.trac.log combined
</VirtualHost>

You also need to uncomment the AddHandler line in /etc/apache2/apache2.conf so that the Trac CGI program will be executed:

# To use CGI scripts outside /cgi-bin/:
#
AddHandler cgi-script .cgi

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

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

This last step would differ if you were already serving other virtualhosts.

4. Creating Environments

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

sudo mkdir /var/svn
sudo mkdir /var/svn/YourProjectNameHere
sudo mkdir /tmp/YourProjectNameHere
sudo mkdir /tmp/YourProjectNameHere/branches
sudo mkdir /tmp/YourProjectNameHere/tags
sudo mkdir /tmp/YourProjectNameHere/trunk
sudo svnadmin create /var/svn/YourProjectNameHere
sudo svn import /tmp/YourProjectNameHere file:///var/svn/YourProjectNameHere -m "initial import"
sudo rm -rf /tmp/YourProjectNameHere

Some permissions changes and an apache restart are now needed:

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

Test by web-browsing to http://servername/svn/YourProjectNameHere

If you see a simple web page which says Revision 1: / and lists branches, tags, and trunk, your Subversion install is up and running!

Now let's finish the Trac install (but don't go on to Trac install until you have the above working properly).

I put my trac environment at /var/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/trac
sudo trac-admin /var/trac/YourProjectNameHere initenv
sudo chown -R www-data /var/trac/YourProjectNameHere

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

  • the project name (YourProjectNameHere)
  • the path to svn repository (/var/svn/YourProjectNameHere)
  • the path to the Trac templates directory (/usr/share/trac/templates)

… 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/cgi-bin/trac.cgi

At the time I did my install, there was one glitch in the Ubuntu Universe Trac installer. It doesn't install the neo_cgi.so file needed in the python2.4 directory space. So when I surfed to my Trac site, I got the error ImportError: No module named neo_cgi. I was able to fix this by symlinking the python2.3 version like so:

sudo ln -s /usr/lib/python2.3/site-packages/neo_cgi.so /usr/lib/python2.4/site-packages/neo_cgi.so

Voila! Your Trac system & website should be up and running.

Comments & Suggestions

  • Celebrate with beer.
Note: See TracWiki for help on using the wiki.