Edgewall Software

How to install Trac 0.12 on Ubuntu 11.10 with Apache2 using WSGI

Notice: These instructions are incomplete. See http://robertbasic.com/blog/trac-on-ubuntu for more detailed instructions.

Every time I use vim you can use any editor you want, such as nano or gedit.

Install Trac and some useful plugins from the repository:

sudo apt-get install trac trac-accountmanager trac-graphviz trac-icalviewplugin trac-mastertickets trac-wysiwyg trac-wikitablemacro trac-tags trac-customfieldadmin trac-datefieldplugin

If you're going to use sqlite for the database, then install python-sqlite:

sudo apt-get install sqlite3 python-sqlite

Install sendmail (if not installed already):

sudo apt-get install sendmail

Add Trac user

sudo adduser --system --shell /bin/sh --gecos 'trac project management' --group --disabled-password --home /var/trac trac

Add www-data to Trac group so Apache can access Trac files:

sudo adduser www-data trac

Login as Trac user start bash and switch to the home directory:

sudo su trac
bash
cd

Make directory for all projects and create new project

mkdir projects
cd projects
trac-admin android initenv
trac-admin android deploy android/deploy

and finish installation.

Change permissions so group can write/read/execute

chmod 0775 . -R

You can add as many projects as you want and at any point in time. All you have to do is create a new project, deploy it and you're set.

Back to your user

Pressing Ctrl-D twice should get you back.

Configure Apache webserver

Open the Apache site file that you want to use for Trac. The default file should be fine. In my case I have Virtualhost for subdomain Trac:

vim /etc/apache2/sites-enabled/trac

and it looks like:

<VirtualHost *>
  ServerName trac.domain.my
  DocumentRoot /var/trac/projects

  WSGIScriptAliasMatch ^/([^/]+) /var/trac/projects/$1/deploy/cgi-bin/trac.wsgi
  <Directory /var/trac/projects>
    WSGIApplicationGroup %{GLOBAL}
    Options Indexes +ExecCGI +SymLinksIfOwnerMatch
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>

  <LocationMatch /[^/]+/login>
   AuthType Basic
   AuthName "trac"
   AuthUserFile /var/trac/.passwd
   Require valid-user
  </LocationMatch>

... trac unrelated stuff...

</VirtualHost>

WSGIScriptAlias does all the magic. It gets its project name from url and redirects to trac.wsgi in that project.

If you're not running Trac sites as a subdomain but as a folder in your documentroot (i.e. domain.ur/trac/myproject), then replace:

^/([^/]+)

with:

^/trac/([^/]+)

(there's just added 'trac/'). And make sure that /var/trac/projects is in DocumentRoot.

Reload Apache configuration

sudo service apache2 reload
Last modified 2 months ago Last modified on Oct 16, 2017, 7:37:00 PM
Note: See TracWiki for help on using the wiki.