Installing Trac on Debian with Apache2, mod_fcgid

I followed Trac instruction installation as you can find them on trac’s website (see debian specific instructions) and as described in my book.

Anyway everything worked fine until the very last step, ie. when you create your project and go into your web browser to log into track.
All I got was a page with the list of projects, and when i clicked on my project, I ended with an apache error: file not found.

First things first, if you bypass Apache and use Trac own server (launch “tracd –port 8000 /path/to/your/project”) and connect to trac through your webbrowser ( it works!

But each time I tried to use apache instead (either through cgi or fastcgi (.cgi and .fcgi resp.)) I ended in an error.

Then I looked at apache error log (/etc/log/apache2/error.log) and found a nasty error msg: [error] script not found or unable to stat: /path/to/trac/binaries/cgi-bin/trac.(f)cgimyprojectname
It looks like we have a problem with the location of my projects.
In apache http.conf, I defined the following env variable: SetEnv TRAC_ENV_PARENT_DIR /path/to/my/projects

TRAC_ENV_PARENT_DIR is used when you want to use trac with multiple projects.
To try to find the source of my error, I commented this variable and defined the variable dedicated to handle a single project: SetEnv TRAC_ENV /path/to/my/project
I restarted apache2 and now I have at least errors showing up! An exception telling me that I should have made my project folder writable by apache user (www-data) as explained in trac installation document (but not in my book).

Once “chgrp -R www-data trac” and “chmod -R g+w trac”, a quick refresh on webbrowser and it works! yes
It’s not a complete victory though, since we still need to deal with the multiple project variable, and displayed html has no css… ;(

A quick look at apache error logs, and we find the same error: [error] script not found or unable to stat: /path/to/trac/binaries/cgi-bin/trac.cgichrome
Well it looks like we still have a problem with our path.
One more time, all this situation is really strange because everything works fine with tracd webserver.

I searched the web for my error msg and found a matching entry in an irc conversation. The solution that seemed to work was for the guy to use mod_python instead of fcgid. Since I am more thant fed up with this problem, I’ve decided to give a go to mod_python solution. Therefore I did the following:

  1. installed mod_python (apt-get install libapache2-mod-python)
  2. edited my matching httpd.conf file for my website (located in /etc/apache2/sites-available/ folder) and added the following entries
  3. <Location /projects/myproject>
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /var/trac/myproject
  4. Then I restarted Apache, mod_python was working but I still got no css loaded (chrome failed to load)
  5. I refered one more time to official documentation to find out that you may need to specify a value for environment variable TracUriRoot that must match your uri in defined in your <Location> node
  6. I added it:
    <Location /projects/myproject>
    SetHandler mod_python
    PythonInterpreter main_interpreter
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /var/trac/myproject
    PythonOption TracUriRoot /projects/myproject
  7. restart apache2 (/etc/init.d/apache2 restart)
  8. refresh your browser and it’s working! Great.

Now we need to deal with the multiple project handling. In my httpd.conf file, I replaced “PythonOption TracEnv /var/trac/myproject” with “PythonOption TracEnvParentDir /path/to/my/projects”.
I’ve restarted apache, refreshed the browser (don’t forget to clear cache…) and it works!!!

At last! what a pain it was… Thank god anyway, it’s working now.

What’s the conclusion of all this? Always goes back to documentation from the source (and do not trust religiously third party docs).

PS: I suppose this god damn TracUriRoot was the problem I had using fcgid where I should have defined it too using SetEnv directive in httpd.conf, but having lost enough time on this, I will stick with mod_python


  • (trac official documentation on mod_python)
  • (trac official installation guide)
  • (good tutorial on installing trac on debian)
  • (good tips to check mod_python is up and running)
  • (irc backups where I found people with the same problem — look for “trac.cgichrome”)

Trac Configuration

Don’t forget to restrict access to svn files through trac using “Require valid-user” apache directive in .htaccess (read ebook instructions)

Since Trac0.11 you can restrict access to wiki pages too. Refer to for more details (
Problem is that it uses a separate auth file => don’t forget to update it with new users… (and to start all your wiki pages with PrivateXXX)

Post a Comment

Your email is never published nor shared. You're allow to say what you want...