[Rails] lighttpd with Rails + PHP

Philip Hallstrom
Thu, 20 Apr 2006 22:00:22 -0000

> How can i make lighttpd work with rails and php?

This works for me:

server.indexfiles    = ("index.php", "index.html",
"dispatch.fcgi")
server.error-handler-404 = "/dispatch.fcgi"
static-file.exclude-extensions = (".php", ".pl",
".cgi", ".fcgi")
$HTTP["host"] == "mydomain.com" {
         server.document-root = "/home/philip/cpr/web/public/"
         server.error-handler-404 = "/dispatch.fcgi"
         fastcgi.server = (
                 ".php" => (
                         (
                         "bin-path" =>
"/usr/local/bin/php-cgi",
                         "socket" => "/tmp/php.socket",
                         "broken-scriptfilename" =>
"enable"
                         )
                 ),
                 ".fcgi" => (
                         (
                         "host" => "127.0.0.1",
                         "port" => 8003,
                         "bin-environment" => (
"RAILS_ENV" => "development")
                         ),
                         (
                         "host" => "127.0.0.1",
                         "port" => 8004,
                         "bin-environment" => (
"RAILS_ENV" => "development")
                         ),
                         (
                         "host" => "127.0.0.1",
                         "port" => 8005,
                         "bin-environment" => (
"RAILS_ENV" => "development")
                         ),
                 )

         )
}

I start up my fast cgi processes for rails like this:

script/process/spawner -p 8003 -i 3 -e development

and /usr/local/bin/php-cgi is the FCGI version of php.

Any PHP files in public get executed via PHP.

Seems to work.