running multiple domains off a single rails app with different page caching directories
Lighttpd config:
1 #... normal lighty conf... 2 server.document-root = "/home/rails/app/public/" 3 server.error-handler-404 = "/dispatch.fcgi" 4 fastcgi.server = ( 5 ".fcgi" => 6 ("localhost" => 7 ( 8 "min-procs" => 1, 9 "max-procs" => 1, 10 "socket" => "/tmp/rails-fcgi1.socket", 11 "bin-path" => "/home/rails/app/public/dispatch.fcgi", 12 "bin-environment" => ( 13 "RAILS_ENV" => "production", 14 "TZ" => "America/Chicago" 15 ) 16 ) 17 ) 18 ) 19 20 $HTTP["host"] =~ "site1.net" { 21 server.document-root = "/home/rails/app/public/site1.net" 22 } 23 $HTTP["host"] =~ "site2.net" { 24 server.document-root = "/home/rails/app/public/site2.net" 25 }
Rails code to set the page cache directory:
1 before_filter { |c| c.class.page_cache_directory = "#{RAILS_ROOT}/public/#{c.request.host}" }
Remember to symlink your necessary files AND your dispatch.fcgi to each page cache directory.