Moved the first Ruby on Rails site from Apache to Lighttpd

Yesterday I managed to move the first Ruby on Rails site to its new home on the VPS. The move had been easier if I hadn’t decided to use Lighttpd this time around, but finally I got everything working. The site I moved is only the administration interface for the energy drink database used by taurin.se, but now I should be able to move that site too. The administration interface should probably also be upgraded from its ancient Ruby on Rails version, but I’m saving that for later. (Technical debt again?)

The Ruby on Rails parts of my Lighttpd configuration currently consists of a $HTTP[“host”] conditional like this:

$HTTP["host"] == "admin.taurin.se" {
    var.site = "admin.taurin.se"
    var.RAILS_ENV = "production"
    include "incl-rubyonrails.conf"
}

And the hopefully reusable include file incl-rubyonrails.conf looks like this:

server.document-root        = basedir + site + "/public"
server.indexfiles           = ( "dispatch.fcgi", "index.html" )
server.error-handler-404    = "/dispatch.fcgi"

fastcgi.server =  (".fcgi" => ( site =>
(
"socket" => "/tmp/" + site + ".fastcgi",
"bin-path" => basedir + site + "/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => RAILS_ENV )
)
))

The var.basedir variable is also set before including the file above.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.