Example lighttpd config for a Rails app
I thought I'd share my lighttpd config file. My main application driving http://www.standardbehaviour.com is at ~/web/, which means the dispatch.fcgi file is in ~/web/public/dispatch.fcgi.
Hope this helps anyone.
# Modules to load {{{1 server.modules = ( "mod_rewrite", "mod_redirect", "mod_access", "mod_fastcgi", "mod_compress", "mod_accesslog" ) # }}}1 # files to check for if .../ is requested # Mimetype mapping {{{1 mimetype.assign = ( ".pdf" => "application/pdf", ".sig" => "application/pgp-signature", ".spl" => "application/futuresplash", ".class" => "application/octet-stream", ".ps" => "application/postscript", ".torrent" => "application/x-bittorrent", ".dvi" => "application/x-dvi", ".gz" => "application/x-gzip", ".pac" => "application/x-ns-proxy-autoconfig", ".swf" => "application/x-shockwave-flash", ".tar.gz" => "application/x-tgz", ".tgz" => "application/x-tgz", ".tar" => "application/x-tar", ".zip" => "application/zip", ".mp3" => "audio/mpeg", ".m3u" => "audio/x-mpegurl", ".wma" => "audio/x-ms-wma", ".wax" => "audio/x-ms-wax", ".ogg" => "audio/x-wav", ".wav" => "audio/x-wav", ".gif" => "image/gif", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".xbm" => "image/x-xbitmap", ".xpm" => "image/x-xpixmap", ".xwd" => "image/x-xwindowdump", ".css" => "text/css", ".html" => "text/html", ".htm" => "text/html", ".js" => "text/javascript", ".asc" => "text/plain", ".c" => "text/plain", ".conf" => "text/plain", ".text" => "text/plain", ".txt" => "text/plain", ".dtd" => "text/xml", ".xml" => "text/xml", ".mpeg" => "video/mpeg", ".mpg" => "video/mpeg", ".mov" => "video/quicktime", ".qt" => "video/quicktime", ".avi" => "video/x-msvideo", ".asf" => "video/x-ms-asf", ".asx" => "video/x-ms-asf", ".wmv" => "video/x-ms-wmv", ".bz2" => "application/x-bzip", ".tbz" => "application/x-bzip-compressed-tar", ".tar.bz2" => "application/x-bzip-compressed-tar" ) # }}} server.document-root = "/home/mveldthuis/web/public/" server.bind = "standardbehaviour.com" server.port = 8534 server.pid-file = "/home/mveldthuis/var/run/lighttpd.pid" server.tag = "lighttpd" server.username = "mveldthuis" server.groupname = "mveldthuis" accesslog.filename = "/home/mveldthuis/var/log/lighttpd.access.log" server.errorlog = "/home/mveldthuis/var/log/lighttpd.error.log" server.indexfiles = ( "index.php", "index.html", "index.htm", "default.htm" ) url.access-deny = ( "~", ".inc" ) # Main site, I want this on www or no www, and on .com, .net and .org $HTTP["host"] =~ "(www\.)?standardbehaviour\.(com|net|org)" { server.document-root = "/home/mveldthuis/web/public/" server.error-handler-404 = "/dispatch.fcgi" fastcgi.server= (".fcgi" => ("StandardBehaviour.com" => ( "socket" => "/home/mveldthuis/var/lighttpd-fcgi.socket", "bin-path" => "/home/mveldthuis/web/public/dispatch.fcgi", "bin-environment" => ("RAILS_ENV" => "production" ), "max-load-per-proc" => 4, "min-procs" => 1, "max-procs" => 2, "idle-timeout" => 60 ) ) ) } # This is the images subdomain, serves mainly just the files, # but I have fileNice there which is PHP. $HTTP["host"] =~ "images\.standardbehaviour\.(com|net|org)" { server.document-root = "/home/mveldthuis/subdomains/images/" server.dir-listing = "enable" server.indexfiles = ("index.php") server.error-handler-404 = "/index.php" fastcgi.server = (".php" => ("ImagesStandardBehaviour" => ("socket" => "/home/mveldthuis/var/lighttpd-images-php.socket", "bin-path" => "/usr/local/www/cgi-bin/php5-fcgi", "bin-environment" => ("PHP_FCGI_CHILDREN" => "1", "PHP_FCGI_MAX_REQUESTS" => "2500" ) ) ) ) } # Pretty much the same as images, but then for experiments. $HTTP["host"] =~ "experiments\.standardbehaviour\.(com|net|org)" { server.document-root = "/home/mveldthuis/subdomains/experiments/" server.dir-listing = "enable" server.indexfiles = ("index.php", "index.html") fastcgi.server = (".php" => ("ImagesStandardBehaviour" => ("socket" => "/home/mveldthuis/var/lighttpd-images-php.socket", "bin-path" => "/usr/local/www/cgi-bin/php5-fcgi", "bin-environment" => ("PHP_FCGI_CHILDREN" => "1", "PHP_FCGI_MAX_REQUESTS" => "2500" ) ) ) ) }
Hope this helps anyone.