如果指定路径上不存在静态文件,如何配置Lighttpd来调用FastCGI应用程序? Lighttpd中的FastCGI模块支持配置选项“check-local”。如果设置为“enable”,Lighttpd将检查所请求的文件是否存在于文档根目录中。它将返回文件(如果存在)或响应404错误。但是,如果文件不存在,FastCGI应用程序将不会执行。
我想实现以下场景:
我在Lighttpd中使用以下配置:
server.modules += ( "mod_fastcgi" )
$HTTP["host"] == "localhost" {
fastcgi.server += ( "/" =>
((
"bin-path" => "/path/to/fcgi/app",
"socket" => "/var/run/lighttpd/foobar.socket",
"max-procs" => 8,
"check-local" => "disable"
))
)
}
修改 我刚刚找到了解决方法。也许有更好的解决方案?
server.modules += ( "mod_fastcgi" )
server.modules += ( "mod_rewrite" )
$HTTP["host"] == "localhost" {
url.rewrite-if-not-file = (
"^(.*)$" => "$1?create=true"
)
$HTTP["querystring"] =~ "create=true" {
fastcgi.server += ( "/" =>
((
"bin-path" => "/path/to/fcgi/app",
"socket" => "/var/run/lighttpd/foobar.socket",
"max-procs" => 8,
"check-local" => "disable"
))
)
}
}