4

I'm trying to set up Trac to test out it's functionality, and the only guides I can find online talk about setting up a VirtualHost. Right now I am under the impression that I need access to a DNS server to properly use the VirtualHost directive, and for various reasons I don't have access to one. Is it possible to set up Trac without setting up a VirtualHost? I haven't had any luck. If I run the site with tracd, it works - which means that at least part of it is set up properly.

Right now all I have is an Apache Directory directive pointing to /pathToTracSite/htdocs/, and when I visit the trac location, all I get when viewing the site from a browser is an empty directory (which makes sense, because htdocs/ is empty).

My server is running Apache2

I know I'm missing a lot here, because I don't understand Apache the Trac system very well - any help would be appreciated.

4 Answers 4

9

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>
2
  • Thanks for putting such a detailed explanation up Walter! Just a quick correction for anyone who wants to use this post: the eggs directory is /trac/eggs/, not /trac/apache/. Also, the wsgi file Walter is referring to in the second step is the trac.wsgi that he lists later. Works great!
    – jobu1324
    Jun 30, 2009 at 0:27
  • Fixed issues listed by jobu1324 in main answer.
    – Walter
    Jun 30, 2009 at 1:49
1

Trac also works fine in a /Location

0

You don't need to make DNS changes to use a virtualhost, an /etc/hosts entry on your client machine will also work fine. You also don't need to run Apache; tracd will do the job just fine for testing purposes.

0

Great tip!! I had problems running Trac on mod_python and I used these instructions to change it to mod_wsgi. Shall add some corrections though

  1. Use apt-get or yum to install libapache2-mod-wsgi package
  2. Trac install essentially refers to your projects location where you did your trac-admin initenv
  3. Apache conf (in ubuntu) is present in /etc/apache2/conf.d/ folder. YOu need to create a file, lets say trac, to add the routing information. The first statement defines the URL. In the example given here /trac is mapped to /trac/apache/trac.wsgi here /trac will be your webservers root.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .