Context Navigation

Trac with FastCGI

Since version 0.9, Trac supports being run through the FastCGI interface. Like mod_python, this allows Trac to remain resident, and is faster than external CGI interfaces which must start a new process for each request. However, unlike mod_python, it is able to support SuEXEC. Additionally, it is supported by much wider variety of web servers.

Note for Windows: Trac's FCGI does not run under Windows, as Windows does not implement Socket.fromfd, which is used by _fcgi.py

Simple Apache configuration

There are two FastCGI modules commonly available for Apache: mod_fastcgi and
mod_fcgid. The FastCgiIpcDir and FastCgiConfig directives discussed
below are mod_fastcgi directives; the DefaultInitEnv is a mod_fcgid
directive.

For mod_fastcgi, add the following to an appropriate Apache configuration
file:

But neither of these will work for mod_fcgid. A similar but partial
solution for mod_fcgid is:

DefaultInitEnv TRAC_ENV /path/to/env/trac/

But this cannot be used in Directory or Location context, which makes it
difficult to support multiple projects.

A better method which works for both of these modules (and for lighttpd and CGI as well), because it involves
no server configuration settings for environment variables, is to set one
of the variables in trac.fcgi, e.g.:

Using this method, different projects can be supported by using different
.fcgi scripts with different ScriptAliases, copying and appropriately
renaming trac.fcgi and adding the above code to create each such script.

Simple Cherokee Configuration

Configuration wanted.

Simple Lighttpd Configuration

The FastCGI front-end was developed primarily for use with alternative webservers, such as lighttpd.

lighttpd is a secure, fast, compliant and very flexible web-server that has been optimized for high-performance
environments. It has a very low memory footprint compared to other web servers and takes care of CPU load.

For using trac.fcgi with lighttpd add the following to your lighttpd.conf:

Note that you will need to add a new entry to fastcgi.server for each separate Trac instance that you wish to run. Alternatively, you may use the TRAC_ENV_PARENT_DIR variable instead of TRAC_ENV as described above,
and you may set one of the two in trac.fcgi instead of in lighttpd.conf
using bin-environment (as in the section above on Apache configuration).

For using two projects with lighttpd add the following to your lighttpd.conf:

Note that field values are different. If you prefer setting the environment
variables in the .fcgi scripts, then copy/rename trac.fcgi, e.g., to
first.fcgi and second.fcgi, and reference them in the above settings.
Note that the above will result in different processes in any event, even
if both are running from the same trac.fcgi script.

Note from c00i90wn: It's very important the order on which server.modules are loaded, if mod_auth is not loaded BEFORE mod_fastcgi, then the server will fail to authenticate the user.

For authentication you should enable mod_auth in lighttpd.conf 'server.modules', select auth.backend and auth rules:

The technique can be easily adapted for use with multiple projects by creating aliases for each of them, and wrapping the fastcgi.server declarations inside conditional configuration blocks.
Also there is another way to handle multiple projects and it's to use TRAC_ENV_PARENT_DIR instead of TRAC_ENV and use global auth, let's see an example:

Relaunch lighttpd, and browse to http://yourhost.example.org/trac to access Trac.

Note about running lighttpd with reduced permissions:

If nothing else helps and trac.fcgi doesn't start with lighttpd settings server.username = "www-data", server.groupname = "www-data", then in the bin-environment section set PYTHON_EGG_CACHE to the home directory of www-data or some other directory accessible to this account for writing.

The FastCGI front-end was developed primarily for use with alternative webservers, such as LiteSpeed.

LiteSpeed? web server is an event-driven asynchronous Apache replacement designed from the ground-up to be secure, scalable, and operate with minimal resources. LiteSpeed? can operate directly from an Apache config file and is targeted for business-critical environments.

Setup

1) Please make sure you have first have a working install of a Trac project. Test install with “tracd” first.

2) Create a Virtual Host for this setup. From now on we will refer to this vhost as TracVhost?. For this tutorial we will be assuming that your trac project will be accessible via: