4

I need to serve some FCGI scripts (via WSAPI, but that is irrelevant) from nginx.

Currently I'm using spawn_fcgi to do this. This is the only solution I've found.

I need to know my other options. Are there any other ways to run FastCGI under nginx?

Alexander Gladysh
  • 2,423
  • 8
  • 31
  • 49

4 Answers4

5

I personally prefer to decouple my FCGI processes from the webserver as much as possible, and manage them as I would any other daemon. In my case, I've switched all of that sort of thing to use daemontools, because it's small, lightweight, is very reliable, and does exactly what you need in this instance, with no mess or fuss.

womble
  • 96,255
  • 29
  • 175
  • 230
  • Thanks for daemontools! I had re-invented the wheel twice, and you've just pointed me at the solution :) – kolypto Nov 07 '09 at 00:16
  • Interesting solution, thanks. Have you compared performance with other solutions? – Alexander Gladysh Nov 07 '09 at 11:04
  • 1
    There's no performance difference, because the actual operation of the FCGI process is the same. Increased performance comes from multiple FCGI listeners load-balanced in the frontend, or else one FCIG listener that delegates requests to multiple threads or child processes. This is out of scope for a discussion of the launcher, though. – womble Nov 07 '09 at 12:07
  • Out of scope, indeed. But I want to read up on the subject. Do you have a link? (I'll create a new question if needed.) – Alexander Gladysh Nov 07 '09 at 17:57
  • Definitely worth a new question. – womble Nov 07 '09 at 23:39
  • @Alexander: did you create a new question like you mentioned above? i searched all your questions but did not find it, also i searched all of Mr womble's answers but no luck. – Viren Shakya Aug 18 '12 at 02:13
  • Nope. Please do, and post a link here so we all can follow. – Alexander Gladysh Aug 20 '12 at 05:23
2

Yet again nobody mentioned php-fpm. It's now bundled with php itself so you should read docs about php-fpm in PHP manual.

SaveTheRbtz
  • 5,691
  • 4
  • 32
  • 45
0

Potentially there's cgi-fcgi. What don't you like about the current method you're using?

user6373
  • 174
  • 4
  • Not that I don't like something specific... I have not enough data for that (yet). I've just overheard some vague and unspecific negative opinions about spawn_fcgi. I'm trying to find out what else I can use just in case. – Alexander Gladysh Nov 06 '09 at 22:57
  • Note that I'm talking about high load (up to C10K) situation. – Alexander Gladysh Nov 06 '09 at 22:58
-1

Theoretically, there are 3 options how PHP can be attached to nginx:

  1. Module. Currently, there's no nginx PHP module. Minus.
  2. CGI. PHP is spawned at every request, and a single php process parses a single php file. execve() overhead is obvious. Dirty Plus.
  3. FCGI. Pre-spawned processes which handle requests, and never stop. Plus.

There's 2 methods of creating these FCGI processes:

  1. Pre-launch them. That's what spawn_fcgi does, and that is okay.
  2. Let nginx launch them: nginx tries to connect to localhost:, and if there's nobody listening, spawns php FCGI workers. That would have been better in terms of administration comfort and stability, but I've never heard of such a module for nginx :) Maybe, you'll be the first one to develop it? ;)

spawn script is not evil, really :)

P.S. Походу, самый пытливый ум у русских ;)

kolypto
  • 11,058
  • 12
  • 54
  • 66