LighttpdOnRails » History » Revision 11
Revision 10 (stbuehler, 2009-04-03 21:24) → Revision 11/17 (stbuehler, 2009-04-03 21:36)
h1. Ruby on Rails with Lighttpd h2. Starting the A document is available at http://old.bougyman.com/RailsonDebian.html which contains step by step instructions on setting rails application In lighttpd 1.4 you have the option to spawn FastCGI backends from lighttpd up with the "bin-path" option; but it is recommend to use [[spawn-fcgi:WikiStart|spawn-fcgi]] for that. Use something like this with daemontools to supervise your rails backends: (./run script, you need a public/dispatch.fcgi for this; most rails applications provide it or an example which you can use) <pre> #!/bin/sh # needs spawn-fcgi lighttpd. A more abbreviated version >= 1.6 exec 2>&1 export RAILS_ENV=production export LANG=en_US.UTF-8 # www-data (different author, i believe jawong) is the user lighty runs as available at http://wiki.rubyonrails.com/rails/show/Lighttpd . exec /usr/bin/spawn-fcgi -s /var/run/lighttpd/rails-application.sock -n -U www-data -u rails-app-user -- /path/to/rails-application/public/dispatch.fcgi </pre> h2. Lighttpd 1.4 Get "cleanurl.lua":http://nordisch.org./cleanurl.lua from http://nordisch.org./. <pre> $HTTP["host"] == "rails-app.example.org" { server.document-root = "/path/to/rails-application/public/" magnet.attract-physical-path-to = ( "/etc/lighttpd/cleanurl.lua" ) fastcgi.server = ( "dispatch.fcgi" => (( "socket" => "/var/run/lighttpd/rails-application.sock", # if May you don't use spawn-fcgi you may try this: # "bin-path" => "/path/to/rails-application/public/dispatch.fcgi", # "max-procs" => 1, # "bin-environment" => ( # "RAILS_ENV" => "production", # "LANG" => "en_US.UTF-8", # ), # "bin-copy-environment" => ( # "PATH", # ), )) ) } </pre> have happy Railing. h2. Lighttpd 1.5 Get "cleanurl.lua":http://nordisch.org./cleanurl.lua from http://nordisch.org./. <pre> $HTTP["host"] == "rails-app.example.org" { server.document-root = "/path/to/rails-application/public/" magnet.attract-physical-path-to = ( "/etc/lighttpd/cleanurl.lua" ) $HTTP["url"] == "/dispatch.fcgi" { proxy-core.backends = ( "unix:/var/run/lighttpd/rails-application.sock" ) proxy-core.protocol = "fastcgi" proxy-core.allow-x-sendfile = "enable" } } </pre> h2. Using RubyOnRails in a simple-vhost environment Let's say: For an easy setup you want to use [[lighttpd:Docs:ModSimpleVhost|simple-vhost]] "simple-vhost":http://www.lighttpd.net/documentation/simple-vhost.html but still want to separate the rails-installation: <pre> <pre> $HTTP["host"] == "ruby.example.org" { server.document-root = "/var/www/site/public/" fastcgi.server = ... } else $HTTP["host"] =~ "" != "ruby.example.org" { simple-vhost.server-root = "/var/www/servers/" simple-vhost.default-host = "www.example.org" simple-vhost.document-root = "pages" } </pre>