It turns out that my web hosting company is getting serious about me using Fast CGI for emacswiki.org and oddmuse.org. After some fooling around on the webserver, I decided that I needed a local lighttpd installation to get aquainted with the software.
I joined #lighttpd on Freenode and installed it. After a while, I got to a dead end and posted some questions ¹:
fastcgi.server = ( "/my/" => (( "socket" => "/tmp/fcgi-test.socket", "bin-path" => "/Users/Shared/WebSite/FCGI/test.fcgi" ))) cgi.assign = ( ".pl" => "/usr/bin/perl", )
I can now visit `http://localhost/rock.pl` and get the rock.pl to run correctly. That is, plain CGI works.
When I visit `http://localhost/my/food` however, I get a 404 error instead of my test.fcgi being run. Any idea what is going wrong?
Starting the server using `sudo lighttpd -f /Users/Shared/WebSite/Conf/lighttpd.conf` doesn’t produce output at the moment. should it list the processes started?
In the following setup, it looks as if the URL to a non-existing script such as `http://localhost/mu.fcgi` should work just as well as the URL to an existing script such as `http://localhost/test.fcgi`. How come the first one returns a 404 and the second one seems to work? Doesn’t the first one (non-existing mu.fcgi) trigger the same .fcgi pattern?
fastcgi.server = ( ".fcgi" => (( "socket" => "/tmp/fcgi-test.socket", "bin-path" => "/Users/Shared/WebSite/Pages/test.fcgi", "min-procs" => 1, "max-procs" => 1, "idle-timeout" => 20 )))
I guess my main problem is that I want to run two wikis on a single server. This seems to require the setup using prefixes, but the only setup I have working uses file extensions. I guess I could use one file extension per wiki but boy what a hack.
In the end, this is what worked:
server.document-root = "/Users/Shared/WebSite/Pages" url.rewrite-once = ( "^/test(\?|/|$)" => "/test.fcgi", "^/rock(\?|/|$)" => "/rock.fcgi" ) $HTTP["url"] =~ "/test" { fastcgi.server = ( ".fcgi" => (( "socket" => "/tmp/fcgi-test.socket", "bin-path" => "/Users/Shared/WebSite/Pages/test.fcgi", "min-procs" => 1, "max-procs" => 1, "idle-timeout" => 20 ))) } $HTTP["url"] =~ "/rock" { fastcgi.server = ( ".fcgi" => (( "socket" => "/tmp/fcgi-rock.socket", "bin-path" => "/Users/Shared/WebSite/Pages/rock.fcgi", "min-procs" => 1, "max-procs" => 1, "idle-timeout" => 20 ))) }
With test.fcgi and rock.fcgi being files like the following:
#! /usr/bin/perl use CGI::Fast qw(:standard); $COUNTER = 0; while (new CGI::Fast) { print header; print start_html("Fast CGI Rocks"); print h1("Fast CGI Rocks"), "Invocation number ",b($COUNTER++), " PID ",b($),".", hr; print end_html; }
Note:
1. If you put the .fcgi scripts outside the document root, you will get 404 Not Found errors.
2. I cannot get rid of the .fcgi extension, since using a prefix rule for fastcgi-server did not work (beginning of this page).
#Software #Lighttpd