Install Trac Without Setting Up a VirtualHost in Apache?

If you want trac to run faster, use mod_wsgi (which is faster than mod_python, both of which are faster than CGI). This can be installed as an apache module from source or from a binary package (see yum or apt-get). When install MoinMoin, I found the different between mod_python and wsgi to be significant. Just noticed, your stumbling block is that python web apps have to be configured in Apache before they will run (it doesn't work like PHP or CGI application).

Trac

To setup trac for WSGI:

  • create an apache directory in your trac install (mkdir /trac/apache)
  • create a wsgi file for trac in /trac/apache (listed below)
  • create an eggs directory in your trac install (mkdir /trac/eggs)
  • add the following to your apache conf (use include files for readability)
  • change ownership of trac to the web server (chown -R apache /trac)

Apache conf


 WSGIScriptAlias /trac   /trac/apache/trac.wsgi

 ## This is required if you plan to use HTTP authorization. Without it the
 ## user name won't be passed
 WSGIPassAuthorization On

<Directory /trac/apache >
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
    AuthName "Trac at My Company"
    AuthType Basic
    AuthUserFile /var/secure/authfiles/trac-authfile
    Require valid-user
</Directory >

trac.wsgi


import sys
sys.stdout = sys.stderr

import os
os.environ['TRAC_ENV'] = '/trac'
os.environ['PYTHON_EGG_CACHE'] = '/trac/eggs'

import trac.web.main

application = trac.web.main.dispatch_request

To setup Trac for mod_python, you could follow the instructions at TracModPython, copied here for your reading pleasure:


<Location /projects/myproject>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend 
   PythonOption TracEnv /var/trac/myproject
   PythonOption TracUriRoot /projects/myproject
</Location>

Trac also works fine in a /Location