Configuring Multiple Rails Application with Lighttpd

Published on Author Akhil BansalLeave a comment

I was using lighttpd web server for my Rails applications.
In development mode I was starting lighttpd server from the rails application directory by

lighttpd -D -f config/lighttpd.conf
But I was facing problem when I tried to run multiple rails applications in production mode. After some trials I succeded.

I inserted the following lines of code in my /etc/lighttpd/lighttpd.conf file

$HTTP[“host”]== “domain.com” {

server.error-handler-404 = “/dispatch.fcgi”

server.document-root = “/home/railsapp/public/”

server.errorlog = “/home/railsapp/log/lighttpd.error.log”

accesslog.filename = “/home/railsapp/log/lighttpd.access.log”

url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )

fastcgi.server = ( “.fcgi” => ( “localhost” => (

“min-procs” => 1,

“max-procs” => 1,

“socket” => “/home/railsapp/tmp/sockets/fcgi.socket”,

“bin-path” => “/home/railsapp/public/dispatch.fcgi”,

“bin-environment” => ( “RAILS_ENV” => “production” )

) ) )

}

$HTTP[“host”]== “another.domain.com” {

server.error-handler-404=”/dispatch.fcgi”

server.document-root = “/home/anotherrailsapp/sparitual/public/”

server.errorlog = “/home/anotherrailsapp/log/lighttpd.error.log”

accesslog.filename = “/home/anotherrailsapp/log/lighttpd.access.log”

url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” => “$1.html” )

compress.filetype = ( “text/plain”, “text/html”, “text/css”, “text/javascript” )

compress.cache-dir = “/home/anotherrailsapp/tmp/cache”

fastcgi.server = ( “.fcgi” => ( “localhost” => (

“min-procs” => 1,

“max-procs” => 1,

“socket” => “/home/anotherrailsapp/tmp/sockets/fcgi.socket”,

“bin-path” => “/home/anotherrailsapp/public/dispatch.fcgi”,

“bin-environment” => ( “RAILS_ENV” => “production” )

) ) )

}

Then started the lighttpd server by

lighttpd -D -f /etc/lighttpd/lighttpd.conf

And it worked…

Leave a Reply

Your email address will not be published. Required fields are marked *