<?xml version="1.0" encoding="iso-8859-1"?><!-- $Revision: 1.8 $ --> <sect1 xml:id="install.unix.lighttpd-14" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Lighttpd 1.4 on Unix systems</title> <para> This section contains notes and hints specific to Lighttpd 1.4 installs of PHP on Unix systems. </para> <para> You are highly encouraged to take a look at the <link xlink:href="&url.lighttpd.docs;">Lighttpd trac</link> to get a basic understanding of the lighttpd server. Use the install instructions there before continuing. </para> <para> Fastcgi is the preferred SAPI to connect PHP and Lighttpd. Fastcgi is automagically enabled in php-cgi in PHP5.3, but for older versions configure php with --enable-fastcgi. To confirm that PHP has fastcgi enabled, <code>php -v</code> should contain <code>PHP 5.2.5 (cgi-fcgi)</code> Before PHP 5.2.3, fastcgi was enabled on the php binary (there was no php-cgi). </para> <sect2 xml:id="install.unix.lighttpd-14.lighttpd-spawn"> <title>Letting Lighttpd spawn your processes</title> <para> To configure Lighttpd to connect to php and spawn fastcgi processes, edit lighttpd.conf. Sockets are preferred to connect to fastcgi processes on the local system. </para> <example> <title> Partial lighttpd.conf </title> <screen><![CDATA[server.modules += ( "mod_fastcgi" )fastcgi.server = ( ".php" => (( "socket" => "/tmp/php.socket", "bin-path" => "/usr/local/bin/php-cgi", "bin-environment" => ( "PHP_FCGI_CHILDREN" => "16", "PHP_FCGI_MAX_REQUESTS" => "10000" ) "min-procs" => 1, "max-procs" => 1, "idle-timeout" => 20 )))]]> </screen> </example> <para> The bin-path directive allows lighttpd to spawn fastcgi processes for you. PHP will spawn children according to the PHP_FCGI_CHILDREN environment variable. The "bin-environment" directive sets the environment for the spawned processes. PHP will kill a child process after the number of requests specified by PHP_FCGI_MAX_REQUESTS is reached. The directives "min-procs" and "max-procs" should generally be avoided with PHP. PHP manages its own children and opcode caches like APC will only share among children managed by PHP. If "min-procs" is set to something greater than 1, the total number of php responders will be multiplied PHP_FCGI_CHILDREN (2 min-procs * 16 children gives 32 responders). </para> </sect2> <sect2 xml:id="install.unix.lighttpd-14.spawn-fcgi"> <title>Spawning with spawn-fcgi</title> <para> Lighttpd provides a program called spawn-fcgi to ease the process of spawning fastcgi processes easier. </para> </sect2> <sect2 xml:id="install.unix.lighttpd-14.spawn-php"> <title>Spawning php-cgi</title> <para> It is possible to spawn processes without spawn-fcgi, though a bit of heavy-lifting is required. Setting the PHP_FCGI_CHILDREN environment var controls how many children PHP will spawn to handle incoming requests. Setting PHP_FCGI_MAX_REQUESTS will determine how long (in requests) each child will live. Here's a simple bash script to help spawn php responders. </para> <example> <title>Spawning FastCGI Responders</title> <screen><![CDATA[#!/bin/sh# Location of the php-cgi binaryPHP=/usr/local/bin/php-cgi# File where you want the PIDPHP_PID=/tmp/php.pid# Binding to an address#FCGI_BIND_ADDRESS=10.0.1.1:10000# Binding to a domain socketFCGI_BIND_ADDRESS=/tmp/php.sockPHP_FCGI_CHILDREN=16PHP_FCGI_MAX_REQUESTS=10000env -i PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN \ PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS \ $PHP -b $FCGI_BIND_ADDRESS &echo $! > "$PHP_PID"]]> </screen> </example> </sect2> <sect2 xml:id="install.unix.lighttpd-14.remote-fcgi"> <title>Connecting to remote FCGI instances</title> <para> Fastcgi instances can be spawned on multiple remote machines in order to scale applications. </para> <example> <title>Connecting to remote php-fastcgi instances</title> <screen><![CDATA[fastcgi.server = ( ".php" => (( "host" => "10.0.0.2", "port" => 1030 ), ( "host" => "10.0.0.3", "port" => 1030 )))]]> </screen> </sect2> </sect1><!-- Keep this comment at the end of the fileLocal variables:mode: sgmlsgml-omittag:tsgml-shorttag:tsgml-minimize-attributes:nilsgml-always-quote-attributes:tsgml-indent-step:1sgml-indent-data:tindent-tabs-mode:nilsgml-parent-document:nilsgml-default-dtd-file:"../../manual.ced"sgml-exposed-tags:nilsgml-local-catalogs:nilsgml-local-ecat-files:nilEnd:vim600: syn=xml fen fdm=syntax fdl=2 sivim: et tw=78 syn=sgmlvi: ts=1 sw=1-->