Project

General

Profile

Actions

FrequentlyAskedQuestions » History » Revision 21

« Previous | Revision 21/83 (diff) | Next »
Anonymous, 2005-10-26 03:47


request, and has nothing to do with where the redirect points to. * QUERY_STRING is ''not'' set, so you have to parse the REQUEST_URI yourself to get it. * Likewise, PATH_INFO isn't set. * SCRIPT_NAME is set according to the handler, not according to the original URI.

FastCGI

=== Where is the spawn-php program/script available from? it's mentioned in docs but not available in the distributed package (1.3.7) ===

If you install lighttpd (http://lighttpd.net/download/INSTALL), the spawn-fcgi binary is installed automatically (to /usr/bin/spawn-fcgi by default).

The spawn-php.sh script can be found here: http://www.lighttpd.net/download/spawn-php.sh

=== Is there an su-exec wrapper available? ===

Not right now, but Sune Foldager coded one especially for lighttpd which you can grab [http://cyanite.org/projects/execwrap/ here]. It's very easy to use, but has not yet been extensively tested so a little caution is adviced. On the other hand, the source is so small so it's easy to get a security overview. Instructions and usage examples (with lighttpd) are in the [http://cyanite.org/projects/execwrap/READ_ME README].

=== How do I exclude a certain directory from FastCGI? ===

{{{
$HTTP["url"] =~ "^/no-fcgi/" {
fastcgi.server = ( "/" => ... )
}
}}}

You can also use server.error-handler-404 to redirect all non-existent files to FastCGI (see LighttpdOnRails for an example).

=== I get the error "No input file specified" when trying use PHP ===

See the comments in the [http://php.net/features.commandline PHP docs]. The issue here is that the variable $SCRIPT_FILENAME is not being passed to PHP.

Double check you have this line in your php.ini: {{{
cgi.fix_pathinfo=1
}}}

=== How many php CGI processes will lighttpd spawn? ===

lighttpd has three configuration options that control how many php-cgi processes will run:

  • PHP_FCGI_CHILDREN (defaults to 8 before 4.3.0, 0 after; see below)
  • min-procs (default 4)
  • max-procs (default 4)

When lighttpd starts, it will launch min-procs parent php processes. Each parent process then pre-forks PHP_FCGI_CHILDREN child processes. For example, if min- and max-procs are 4 and PHP_FCGI_CHILDREN is 16, lighttpd will start 4 + 4 x 16 = 68 processes.

To disable lighttpd's process control, set min-procs and max-procs to 1 and set PHP_FCGI_CHILDREN to the number of processes you want to spawn.

In the case of lighttpd 1.4, php 4.3, and eaccelerator 0.9.3 on Linux, eaccelerator will create a separate memory space for each parent process. If you leave min- and max-procs at 4, you'll end up with four separate eaccelerator caches. However, if a php parent segfaults, you'll still have three groups available to respond to queries. For this reason, Jan recommends setting min- and max-procs to 2.

After PHP 4.3.0, PHP_FCGI_CHILDREN defaults to 0. If left at 0, PHP will not pre-fork any children, so only min-procs parents will handle requests.

PHP 5 seems to start one parent process and one child per min/max-procs and PHP_FCGI_CHILDREN defaults to 1. What I suggest is splitting the number of processes you want between min/max-procs and PHP_FCGI_CHILDREN. The number of processes spawned = min/max-procs*(PHP_FCGI_CHILDREN+1). For my setup, I have min-procs and max-procs=2 and PHP_FCGI_CHILDREN=4.

Note that setting PHP_FCGI_MAX_REQUESTS is recommended to avoid possible memory leak side-effects.

=== What does %1/$1 mean? ===

It's just "lighty speak" for [http://www.regular-expressions.info/brackets.html backreferences]. (See doc/rewrite.txt and doc/redirect.txt.)

%n is used to denote a backreference on the conditional, and $n is used to backreference on the redirect/rewrite regex. If you need to learn about regexen, [http://www.regular-expressions.info/ Regular-Expressions.info] is as good a place to start as any.

Updated by Anonymous over 19 years ago · 83 revisions