Unix ƽ̨�� Lighttpd 1.4

���ڰ����� Unix ƽ̨�� Lighttpd 1.4 �°�װ PHP ��˵������ʾ��

�Ƽ��Ķ� » Lighttpd trac �˽�һ����ȷ��װ Lighttpd Ȼ�������

�Ƽ�ʹ�� Fastcgi ��Ϊ SAPI ģ�������� PHP �� Lighttpd���� PHP 5.3 ���Զ������� Fastcgi�����ھɰ汾��������ʱʹ�� --enable-fastcgi��Ҫȷ�� PHP �Ѽ��� Fastcgi ����ʹ������ php -v��Ӧ����ʾ PHP 5.2.5 (cgi-fcgi)���� PHP 5.2.3 ֮ǰ��Fastcgi �ǰ����� php ��ִ���ļ��У�û�� php-cgi �ļ�����

ʹ Lighttpd ���� php ����

Ҫ���� Lighttpd ���ӵ� php ������ fastcgi ���̣��༭ lighttpd.conf���Ƽ�ʹ���׽����ڱ������� fastcgi ���̡�

Example #1 Partial lighttpd.conf

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
  ))
)

bin-path ָ������ lighttpd ��̬���� fastcgi ���̡�PHP ����� PHP_FCGI_CHILDREN �������������ӽ��̡�"bin-environment"ָ���趨���������Ľ��еĻ�����PHP ���ڴﵽ PHP_FCGI_MAX_REQUESTS ��ָ����������Ŀ֮��ɱ��һ���ӽ��̡��� PHP ��ͨ��Ӧ����"min-procs"��"max-procs"ָ�PHP �Լ��������ӽ��̣��������� APC ֮��� opcode ������� PHP �����µ��ӽ���֮�乲�����"min-procs"���趨��ij������ 1 ��ֵ���� PHP Ӧ����������ĿΪ��ֵ���� PHP_FCGI_CHILDREN���� min-procs Ϊ 2��PHP_FCGI_CHILDREN Ϊ 16 ������ 32 ��Ӧ��������

ͨ�� spawn-fcgi ��������

Lighttpd �ṩһ����Ϊ spawn-fcgi �ij������򻯲��� fastcgi ���̵�������

���� php-cgi

�п��ܲ�ͨ�� spawn-fcgi ���������̣�����Ҫ��Щ�������趨 PHP_FCGI_CHILDREN �������������� PHP �������ٸ��ӽ��������������趨 PHP_FCGI_MAX_REQUESTS ������ÿ���ӽ��̴���ã���������Ŀ������������Ϊһ���򵥵� bash �ű����������� php Ӧ������

Example #2 ���� FastCGI Ӧ����

#!/bin/sh

# Location of the php-cgi binary
PHP=/usr/local/bin/php-cgi

# PID File location
PHP_PID=/tmp/php.pid

# Binding to an address
#FCGI_BIND_ADDRESS=10.0.1.1:10000
# Binding to a domain socket
FCGI_BIND_ADDRESS=/tmp/php.sock

PHP_FCGI_CHILDREN=16
PHP_FCGI_MAX_REQUESTS=10000

env -i PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN \
       PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS \
       $PHP -b $FCGI_BIND_ADDRESS &

echo $! > "$PHP_PID"

����Զ�� FCGI ʵ��

Fastcgi ʵ���ɱ������ڶ��Զ�̻����Է�ɢӦ�ó���

Example #3 ����Զ�� php-fastcgi ʵ��

fastcgi.server = ( ".php" =>
   (( "host" => "10.0.0.2", "port" => 1030 ),
    ( "host" => "10.0.0.3", "port" => 1030 ))
)