项目

通用

个人资料

操作

Rails 教程

lighttpd 配置

参见 mod_core 获取 core.cached_html 动作。

setup {
    module_load ( "mod_expire", "mod_fastcgi", "mod_vhost", "mod_lua" );
    lua.plugin "core.lua";
}

var.vhosts = [];

# ...

var.vhosts = var.vhosts + [
    "www.lighttpd.net" => {
        docroot "/var/www/servers/www.lighttpd.net/mephisto/public/";
        index ("index.html");

                # looks for cached pages (with '.html' appended to the url), but only if the file for
                # the original url doesn't exists and doesn't end with '.html' (in the first case we already have a file,
                # in the second case we don't want to append another '.html' - if a file exists for the url we will still find it)
                #
                # remove it if your rails app doesn't cache files, or modify it to look somewhere else (depending on your rails application).
        core.cached_html;

        # deliver static files directly, forward everything else to the rails application
        if physical.is_file {
            header.add ("X-cleanurl", "hit");
        } else {
            header.add ("X-cleanurl", "miss");
            fastcgi "unix:/var/run/lighttpd/sockets/www.lighttpd.net.sock";
        }

        if req.path =~ "\.(png|css|gif)$" {
            expire "access 1 week";
        }
    }
];

# ...

vhost.map var.vhosts;

生成 Rails 应用程序

一个简单的 ./run 脚本,用于通过 spawn-fcgi 和 runit/daemontools 生成 Rails 应用程序。

#!/bin/sh

exec 2>&1

RAILS_ENV="production" \
LANG=C LC_ALL=C \
exec /usr/bin/spawn-fcgi -n -s /var/run/lighttpd/sockets/www.lighttpd.net.sock -u www-default -U www-data -- /var/www/servers/www.lighttpd.net/mephisto/public/dispatch.fcgi

dispatch.fcgi

显然你需要一个 dispatch.fcgi FastCGI 处理程序,如果你没有,可以试试这个

#!/usr/bin/env ruby

require File.dirname(__FILE__) + "/../config/environment" 
require 'fcgi_handler'

RailsFCGIHandler.process!

更新者 stbuehler 大约 11 年前 · 11 个修订版本