There is no official way to disable fcgi for a specific virtual host in lighttpd. After much experimentation, I found a couple of ways to disable fcgi for a specific vhost. This could be useful if you want to disallow php/perl/ruby (or all of them) on a sensible website, or for a specific customer. One possible way was to have a full fastcgi.server for each vhost where it was allowed. This was a bad solution because it will fork a lot of useless php/perl process. And the configuration would quickly become a mess anyway.
I had two goals:
- Find a way to disable all fcgi for the specific vhost.
- Find a way to disable a specific fcgi for the specific vhost. (eg: disable php but allow perl)
The first way is to disable all fcgi for a vhost. It is possible by adding the following snippet inside the vhost (the $HTTP["host"] == "domain.td" {} block):
static-file.exclude-extensions = ()
fastcgi.server = ()
fastcgi.map-extensions = ()
The second way, and most likely the best way since you can have per-fcgi control, is to match on the file name by adding this snippet in the vhost configuration:
$HTTP["url"] =~ ".php$" {
static-file.exclude-extensions = ()
fastcgi.server = ()
}
The last method I tried was using a UUID to declare the fcgi, and then map it to its extension. The main problem with this, it's that if your client see your configuration file somehow, he will be able to run a script by renaming it to the UUID.
First, use a UUID instead of an extension to declare your fcgi servers:
fastcgi.server = ( "034343-43423423-php-342423" => ((
"max-procs" => 1,
"bin-path" => "/usr/bin/php-cgi",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "3",
"PHP_FCGI_MAX_REQUESTS" => "250"
),
"socket" => "/tmp/php.socket"
)),
"034343-43423423-ruby-342423" => ((
"max-procs" => 1,
"bin-path" => "/usr/bin/custom-fcgi",
"bin-copy-environment" => ("LANG", "TERM"),
"socket" => "/tmp/ruby.socket"
))
)
fastcgi.map-extensions = (".php" => "034343-43423423-php-342423", ".rb" => "034343-43423423-ruby-342423" )
And then redeclare the map-extensions inside the vhost configuration according to what you want to allow:
Eg, to disable php:
fastcgi.map-extensions = (".rb" => "034343-43423423-ruby-342423" )
I hope that one of those methods will help you!


![privacy[1]](http://blog.alexou.net/wp-content/uploads/2010/08/privacy1-300x214.jpg)