Project

General

Profile

HowToSetupTrac » History » Revision 17

Revision 16 (rsenk330, 2009-12-16 00:24) → Revision 17/18 (mathieumg, 2011-02-10 22:28)

h1. How to setup trac with Lighttpd 


 "Trac":http://trac.edgewall.org/ is an enhanced wiki and issue tracking system for software development projects. 


 h2. Common setup using FastCGI 

 <pre> 
 $HTTP["host"] == "trac.example.com" { 
     server.document-root = "/www/htdocs/sites/trac.example.com" 
     alias.url              = ( 
         "/trac_prefix/chrome/common/" => "/usr/share/trac/htdocs/", 
     ) 
 
     # rewrite for multiple svn project 
     url.rewrite-final      = ( 
         "^/trac_prefix/[^/]+/chrome/common/(.*)" => "/trac_prefix/chrome/common/$1", 
     ) 


     $HTTP["url"] =~ "^/trac_prefix/chrome/" { 
         # no fastcgi 
     } # end of $HTTP["url"] =~ "^/trac_prefix/chrome/" 
     else $HTTP["url"] =~ "^/trac_prefix" { 
         fastcgi.server      = ( 
             "/trac_prefix" => (            # if trac_prefix is empty, use "/" 
                 ( 
                     # options needed to have lighty spawn trac 
                     "bin-path"          => "/usr/share/webapps/trac/0.9.3/hostroot/cgi-bin/trac.fcgi", 
                     "min-procs"         => 1, 
                     "max-procs"         => 1, 
                     "bin-environment" => ( 
                         "TRAC_ENV_PARENT_DIR" => "/var/lib/trac/", 
                     ), 

                     # options needed in all cases 
                     "socket"            => "/tmp/trac.sock", 
                     "check-local"       => "disable", 

                     # optional 
                     "disable-time"      => 1, 

                     # needed if trac_prefix is empty; and you need >= 1.4.23 
                     "fix-root-scriptname" => "enable", 
                 ), 
             ), 
         ) 
     } # end of $HTTP["url"] =~ "^/trac_prefix" 
 } # end of $HTTP["host"] == "trac.example.com" 
 </pre> 


 Change "/trac_prefix" (neither "/trac_prefix/" nor "trac_prefix/", nor "trac_prefix") to anything else or even remove it if you want. 

 If you only want one svn project, then replace "TRAC_ENV_PARENT_DIR" with "TRAC_ENV" and change "/var/lib/trac" to the correct subdirectory. 

 You can use [[spawn-fcgi:|spawn-fcgi]] to spawn the trac application too, of course. 
 <pre> 
 TRAC_ENV_PARENT_DIR=/var/lib/trac/ spawn-fcgi -n -s /tmp/trac.sock -- /usr/share/webapps/trac/0.9.3/hostroot/cgi-bin/trac.fcgi 
 </pre> 

 h2. Common setup using CGI 

 Take a look at the "updated Trac setup documentation":http://trac.edgewall.org/wiki/TracInstallPlatforms 

 h2. Fedora setup 

 <pre> 
 var.fcgi_binary="/usr/bin/python /usr/lib/python2.5/site-packages/Trac-0.11.4-py2.5.egg/trac/web/fcgi_frontend.py" # Change to point to correct version 
 $HTTP["host"] == "trac.example.com" { 
     fastcgi.server         = ( "/" => 
                              ( "trac" => 
                                ( "socket" => "/tmp/trac-fastcgi.sock", 
                                  "bin-path" => fcgi_binary, 
                                  "check-local" => "disable", 
                                  "bin-environment" => 
                                  ( "TRAC_ENV_PARENT_DIR" => "/path/to/trac", 
 				    "PYTHONPATH" => "/usr/lib/python2.5/site-packages", 
				    "PYTHON_EGG_CACHE" => "/tmp/trac" 
				  ), 
				  "fix-root-scriptname" => "enable", 
                                ) 
                              ) 
                            ) 
     $HTTP["url"] =~ "^/.*/login$" { 
         auth.require = ( "/" => ( 
             "method" => "digest", 
             "realm"    => "Trac", 
             "require" => "valid-user" 
             ) 
         ) 
     } 
 } 
 </pre> 

 h2. Separated setup 

 The webserver at lighttpd.net is living in a chroot which separates the webserver-root from the rest of the system and the subversion repositories. 

 As trac requires physical access it couldn't be installed in the "well documented way":http://trac.edgewall.org/wiki/TracInstall.  

 trac provides a seperated tracd which is started locally at port 9090: 

 <pre> 
 $ tracd -b 127.0.0.1 -p 9090 /path/to/trac/lighttpd/ 
 </pre> 

 Additionally, if you want to access your proxied trac installation with a base url other than /, you can add the following switch to the previous tracd command-line: 

 <pre> 
 --base-path=/some/path 
 </pre> 

 To forward all requests from the webserver to trac the [[lighttpd:Docs:ModProxy]] is used: 

 <pre> 
 $HTTP["host"] == "trac.lighttpd.net" { 
   # forward all requests at trac.lighttpd.net to the tracd 
   proxy.server = ("" => ( "trac" => ( "host" => "127.0.0.1", "port" => 9090 ))) 
 } 
 </pre>