Edgewall Software

Installing Trac on Ubuntu

This is a how-to specifically for Ubuntu users. I wrote these notes during an install on Ubuntu Hardy Heron, which is version 8.04. Read TracInstall first for a general overview.

I consulted:

I ran the following commands as root:

cd /usr/local/src
wget http://ftp.edgewall.com/pub/trac/Trac-0.11.5.tar.gz
tar -zxf Trac-0.11.5.tar.gz
cd Trac-0.11.5
apt-get install python-dev
apt-get install python-xml
apt-get install python-genshi
apt-get install python-subversion
apt-get install python-pysqlite2
apt-get install python-setuptools
apt-get install libapache2-mod-python
python ./setup.py install

Now we need a folder the web server is allowed to write to in which to keep Trac's data. So we'll make that folder and then switch to the www-data user for the next few commands:

mkdir /usr/local/trac
chown www-data.www-data /usr/local/trac
su www-data
svnadmin create /usr/local/trac/repository
trac-admin /usr/local/trac/environment initenv 

The trac-admin command will prompt you for various settings. You can accept the defaults, except for the Subversion repository, which you should set to /usr/local/trac/repository.

htpasswd -c /usr/local/trac/passwords.txt admin

Supply a password for an initial user. You can add more users later. Use the -c option only on the first use of this command, as it creates the password file.

You will want the web admin panel available to the admin user so execute the following:

trac-admin /usr/local/trac/environment permission add admin TRAC_ADMIN

Now it's time to switch back to root to configure Apache. Type exit to log out of the www-data account and return to root. Now set up a virtual host for Trac. Let's say it will be called tractest. You can set it up by creating the file /etc/apache2/sites-available/tractest with the following contents:

<VirtualHost *>
  ServerName tractest
  <Location />
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /usr/local/trac/environment
    PythonOption TracUriRoot /
  <Location /login>
    AuthType Basic
    AuthName "trac"
    AuthUserFile /usr/local/trac/passwords.txt
    Require valid-user


Now, link the site that is available to the list that will startup by default.

ln -s /etc/apache2/sites-available/tractest /etc/apache2/sites-enabled/002-tractest 

Now, as root, signal Apache to reload its configuration and notice the new site:

invoke-rc.d apache2 reload

Finally, add tractest to your DNS or, if you're just setting up a test site for your own use on your own computer, add it to the list of aliases for localhost in your /etc/hosts file:

# List testing sites here localhost tractest

Visit http://tractest/ and you'll have access to Trac. You can log in as the admin user, when you click on the login button.

Of course basic authentication isn't the only option. Anything that is backwards-compatible with it should work, including mod_ldap, mod_shib, etc.

Last modified 8 years ago Last modified on Dec 20, 2015, 3:53:12 PM
Note: See TracWiki for help on using the wiki.