Trac with lighttpd on CentOS

I spent a few hours today trying to figure out how to get trac working with lighttpd on CentOS with the standard packages from rpmforge. Like always this seams to be quite easy but then you spend ages on the little things.

First of all you need to install trac via yum which is quite easy: yum install trac
This is assuming you have lighttpd already installed


So here is the section you have to put in your /etc/lighttpd/lighttpd.conf you will also have to enable a few modules at the start most notably mod_fastcgi but please always check that you have all the modules enabled.

$HTTP["host"] == "trac.mypage.org" {

url.rewrite = ( "^/$" => "/root")

server.document-root = "/var/www/trac"
alias.url = (
"/trac_prefix/chrome/common/" => "/usr/lib/python2.4/site-packages/trac/htdocs/",
)

# rewrite for multiple svn project
url.rewrite-final = (
"^/trac_prefix/[^/]+/chrome/common/(.*)" => "/chrome/common/$1",
)

$HTTP["url"] =~ "^/trac_prefix/chrome/" {
}
else $HTTP["url"] =~ "^/root" {
fastcgi.server = (
"/root" => ( # if trac_prefix is empty, use "/"
(
# options needed to have lighty spawn trac
"bin-path" => "/usr/lib/python2.4/site-packages/trac/web/fcgi_frontend.py",
"min-procs" => 1,
"max-procs" => 1,
"bin-environment" => (
"TRAC_ENV_PARENT_DIR" => "/var/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",
),
),
)
}
}


There is nothing special with the paths and the rest if quite standard. The one thing to note is that I couldn't get trac to live properly in the root directory. As soon as you select a project it will error => So we rewrite the url to add "root" to the end. The rest should be pretty straight forward. There is no authentication in this example but this will follow in a further post.

No comments: