1. Install dependencies:

$ sudo /etc/init.d/apache2 stop
$ sudo apt-get install libapache2-mod-python
$ sudo apt-get install apache2 libapache2-svn
$ sudo apt-get install python-setuptools
$ sudo apt-get install python-pgsql
$ sudo /etc/init.d/apache2 start

2. Create postgres user account “tracuser” and database “trac”

$ sudo su postgres
postgres@mapsys-dev-00: createuser -U postgres -E -P tracuser
postgres@mapsys-dev-00: createdb -U postgres -O tracuser -E UTF8 trac

3. Create trac environment directory (/var/www/trac_projects/mapsys_trac)

$ sudo mkdir /var/www/trac_projects
$ sudo chown -R www-data /var/www/trac_projects
$ sudo mkdir /var/www/trac_projects/mapsys_trac
$ sudo chown -R www-data /var/www/trac_projects/mapsys_trac

4. Install trac

$ sudo apt-get install trac

5. Initialize project with trac-admin

$ cd /var/www/trac_projects
/var/www/trac_projects$ sudo trac-admin mapsys_trac initenv

And then follow the instructions:

Project Name [My Project]> Mapsys
Database connection string [sqlite:db/trac.db]> postgres://tracuser:{password}@localhost/trac
Repository type [svn]>
Path to repository [/path/to/repos]> /repository

6. Change the owner and do a test run with the webuser.

$ sudo chown -R www-data /var/www/trac_projects/mapsys_trac
$ sudo -u www-data tracd –port 8000 /var/www/trac_projects/mapsys_trac

You can test it at: http://localhost:8000

7. Setup Trac to run with apache.

create trac.conf

$ sudo gedit /etc/apache2/sites-available/trac.conf

Configure the following in trac.conf

    <Location /trac> #set up Trac handling

        SetHandler mod_python

        PythonHandler trac.web.modpython_frontend

        PythonOption TracEnvParentDir /var/www/trac_projects

        PythonOption TracUriRoot /trac

        # Use the SVN password file.

        AuthType Basic

        AuthName "Subversion Repository"

        AuthUserFile /etc/apache2/dav_svn.passwd

        Require valid-user  


8. Setup svn password

$ sudo htpasswd -c /etc/apache2/dav_svn.passwd {first-svn-user}
$ sudo htpasswd /etc/apache2/dav_svn.passwd {more-user}
$ sudo /etc/init.d/apache2 restart

9. Install the python module and make the site available

$ sudo apt-get install libapache2-mod-python
$ cd /etc/apache2/sites-enabled
$ sudo ln -s ../sites-available/trac.conf 010-trac
$ sudo /etc/init.d/apache2 restart

10. Modify /etc/apache2/httpd.conf

$ sudo nano /etc/apache2/httpd.conf

Add the following to the end.

    Alias /trac "/var/www/trac_projects/mapsys_trac/htdocs"

    <Location "/cgi-bin/trac.cgi">

        SetEnv TRAC_ENV "/var/www/trac_projects/mapsys_trac"


And then restart apache service

$ sudo /etc/init.d/apache2 restart

Now you can test it at http://localhost/trac

*note the username and password is what you created in step 8

Reference: https://help.ubuntu.com/community/UbuntuTracHowto#Server