Apache config

Configuration instructions for serving Trac with Apache.

TracModMython wiki page with detailed Apache instructions.

Prerequisites
Apache requires mod_python to be installed in order to run Trac.

Simple Configuration
Edit /usr/local/apache2/conf/httpd.conf and add the following to instruct Apache to redirect any URLs starting with "/trac/" to Trac:

<LocationMatch "/trac/.+/">
  SetHandler mod_python
  PythonInterpreter main_interpreter
  PythonHandler trac.web.modpython_frontend
  PythonOption TracEnvParentDir /var/trac
  PythonOption TracUriRoot /trac
</LocationMatch>

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

Virtual Host Configuration
Instructions for configuring Trac as an Apache virtual server so you can acesss it at a URL like trac.mydomain.com, assuming you already have enabled /usr/local/apache2/conf/extra/httpd-vhost.conf:

<VirtualHost * >
  DocumentRoot /var/trac
  ServerName trac.mydomain.com
  <Location />
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnvParentDir /var/trac
    PythonOption TracUriRoot /

    # These 2 lines might not be necessary for your server
    Order allow,deny
    Allow from all
  </Location>
  <LocationMatch /login>
    AuthType Basic
    AuthName "MyDomain Trac Server"
    AuthUserFile /var/svn/.htusers
    Require valid-user
  </LocationMatch>
</VirtualHost>

Project Index Page
Create a file /var/trac/index.html:

<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"
  xmlns:py="http://genshi.edgewall.org/"
  xmlns:xi="http://www.w3.org/2001/XInclude">
<HEAD>
  <TITLE>Available Projects | trac.myserver.com</TITLE>
</HEAD>
<BODY>
  <H1>Available Projects</H1>
  <UL>
    <LI py:for="project in projects" py:choose="">
      <a py:when="project.href" href="$project.href"
      title="$project.description">$project.name</a>
      <py:otherwise>
      <small>$project.name: <em>Error</em> <br /> ($project.description)</small>
      </py:otherwise>
    </li>
  </ul>
</BODY>
</HTML>

Edit your Trac directive in /usr/local/apache2/conf/extra/httpd-vhosts.conf and add:

PythonOption TracEnvIndexTemplate /var/trac/index.html

Recent Updates

  • 1 year 11 months ago
  • 1 year 11 months ago
  • 1 year 12 months ago
    php 8.x
  • 1 year 12 months ago
    10.6.7
  • 1 year 12 months ago
    Drop Centos 5/6 stuff