Caveat
The way CGI works requires that the entire Trac application be reloaded on every request. This ends up being very slow. Use CGI only as a last resort.
To generate the trac.cgi script run:
trac-admin /path/to/env deploy /path/to/www/trac
It will be in the cgi-bin folder inside the path given.
Add an alias for the path you want to run Trac at to your VirtualHost:
ScriptAlias /trac /path/to/www/trac/cgi-bin/trac.cgi
For a multiple environment configuration you can use:
ScriptAlias /trac /path/to/www/trac/cgi-bin/trac.cgi
<Location /trac>
SetEnv TRAC_ENV_PARENT_DIR /path/to/base
</Location>
See Authentication on Apache to setup authentication.