It’s actually REALLY easy with lighttpd on linux.
Two apps…
Myserver.com/code/ => /apps/code/
Myserver.com/test/ +> /apps/test/
Each application needs this in the environment.rb
/apps/code/config/environment.rb
ActionController::AbstractRequest.relative_url_root = “/code”
/apps/test/config/environment.rb
ActionController::AbstractRequest.relative_url_root = “/test”
Here’s a lighttpd config file that runs on port 80. Be sure to activate
mod_alias!!
Default configuration file for the lighttpd web server
Start using ./script/server lighttpd
server.port = 80
server.modules = (“mod_alias”, “mod_rewrite”,
“mod_accesslog”, “mod_fastcgi” )
server.document-root = “/apps/root/”
url.rewrite = ( “^/$” => “index.html”, “^([^.]+)$” =>
“$1.html” )
$HTTP[“url”] =~ “^/code” {
server.document-root = “/apps/code/public/”
alias.url = ( “/code” => “/apps/code/public” )
server.error-handler-404 = “/code/dispatch.fcgi”
server.errorlog = “/apps/code/log/lighttpd.error.log”
accesslog.filename = “/apps/code/log/lighttpd.access.log”
server.indexfiles = ( “dispatch.fcgi”, “index.html” )
fastcgi.server = ( “.fcgi” =>
((
“socket” => “/apps/code/log/code.socket”,
“min-procs” => 2,
“max-procs” => 2,
“bin-path” => “/apps/code/public/dispatch.fcgi”,
“bin-environment” => ( “RAILS_ENV” => “production” )
)))
}
$HTTP[“url”] =~ “^/test” {
server.document-root = “/apps/test/public/”
alias.url = ( “/test” => “/apps/test/public” )
server.error-handler-404 = “/test/dispatch.fcgi”
server.errorlog = “/apps/test/log/lighttpd.error.log”
accesslog.filename = “/apps/test/log/lighttpd.access.log”
server.indexfiles = ( “dispatch.fcgi”, “index.html” )
fastcgi.server = ( “.fcgi” =>
((
“socket” => “/apps/test/log/test.socket”,
“min-procs” => 2,
“max-procs” => 2,
“bin-path” => “/apps/test/public/dispatch.fcgi”,
“bin-environment” => ( “RAILS_ENV” => “production” )
)))
}
mimetype.assign = (
“.css” => “text/css”,
“.gif” => “image/gif”,
“.htm” => “text/html”,
“.html” => “text/html”,
“.jpeg” => “image/jpeg”,
“.jpg” => “image/jpeg”,
“.js” => “text/javascript”,
“.png” => “image/png”,
“.swf” => “application/x-shockwave-flash”,
“.txt” => “text/plain”
)
Doing this with SCGI is just as easy. Just change the appropriate
sections and it should work fine.
Good luck!!!
-Brian