Project

General

Profile

mod_fastcgi + java setup

Added by kitemaster over 16 years ago

Hi

Im trying to run the example application from http://www.fastcgi.com/. I made a runnable jar file and can start it with java -jar TinyFCGI.jar.
But how can i start it with lighttpd and fastcgi support?

I tried it with this config (modified form a php config):

#### fastcgi module
server.modules   += ( "mod_fastcgi" )
fastcgi.debug = 1

fastcgi.server = ( "JavaFCGI.jar" =>
 ( "localhost" =>
   ("port" => 54321,
    "bin-path" => "/usr/bin/java -DFCGI_PORT=54321 -jar /var/www/JavaFCGI.jar",
    "min-procs" => 1,
    "max-procs" => 1,
    "check-local" => "disable" 
 ))
)

When i restart lighttpd it says:

 2009-01-12 20:52:43: (mod_fastcgi.c.1297) --- fastcgi spawning local
        proc: /usr/bin/java -DFCGI_PORT=54321 -jar /var/www/JavaFCGI.jar
        port: 54321
        socket
        min-procs: 1
        max-procs: 1
2009-01-12 20:52:43: (mod_fastcgi.c.1322) --- fastcgi spawning
        port: 54321
        socket
        current: 0 / 1
2009-01-12 20:52:43: (mod_fastcgi.c.1022) the fastcgi-backend /usr/bin/java -DFCGI_PORT=54321 -jar /var/www/JavaFCGI.jar failed to start:
2009-01-12 20:52:43: (mod_fastcgi.c.1026) child exited with status 0 /usr/bin/java -DFCGI_PORT=54321 -jar /var/www/JavaFCGI.jar
2009-01-12 20:52:43: (mod_fastcgi.c.1029) if you try do run PHP as FastCGI backend make sure you use the FastCGI enabled version.
You can find out if it is the right one by executing 'php -v' and it should display '(cgi-fcgi)' in the output, NOT (cgi) NOR (cli)
For more information check http://www.lighttpd.net/documentation/fastcgi.html#preparing-php-as-a-fastcgi-program
2009-01-12 20:52:43: (mod_fastcgi.c.1034) If this is PHP on Gentoo add fastcgi to the USE flags
2009-01-12 20:52:43: (mod_fastcgi.c.1330) [ERROR]: spawning fcgi failed.
2009-01-12 20:52:43: (server.c.862) Configuration of plugins failed. Going down.

Error.log is:

2009-01-12 20:34:18: (log.c.75) server started
2009-01-12 20:35:25: (mod_fastcgi.c.2689) write-req: error 0x080a7f80 0 54321 0

Can someone please help me to set up lighttpd with java?


Replies (2)

RE: mod_fastcgi + java setup - Added by darix over 16 years ago

you can not pass arguments as bin-path. easiest thing would be a wrapper script, that launches java with the correct args.

RE: mod_fastcgi + java setup - Added by kitemaster over 16 years ago

thanks for the tip!

now wrote a script in /var/www/fcgi with the line

java  -DFCGI_PORT=54321 -jar /var/www/JavaFCGI.jar

the lighttpd.conf looks like this

#### fastcgi module
server.modules   += ( "mod_fastcgi" )
fastcgi.debug = 1

fastcgi.server = ( "fcgi" =>
 ( "localhost" =>
   ("port" => 54321,
    "host" => "127.0.0.1",
    "min-procs" => 1,
    "max-procs" => 1,
    "check-local" => "disable" 
 ))
)

Then i have to start the script manually but it works. Thanks!

    (1-2/2)