锟斤拷锟节帮拷锟斤拷锟斤拷 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 锟斤拷执锟斤拷锟侥硷拷锟叫o拷没锟斤拷 php-cgi 锟侥硷拷锟斤拷锟斤拷
要锟斤拷锟斤拷 Lighttpd 锟斤拷锟接碉拷 php 锟斤拷锟斤拷锟斤拷 fastcgi 锟斤拷锟教o拷锟洁辑 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 锟皆硷拷锟斤拷锟斤拷锟斤拷锟接斤拷锟教o拷锟斤拷锟斤拷锟斤拷锟斤拷 APC 之锟斤拷锟� opcode 锟斤拷锟斤拷锟斤拷锟� PHP 锟斤拷锟斤拷锟铰碉拷锟接斤拷锟斤拷之锟戒共锟斤拷锟斤拷锟�"min-procs"锟斤拷锟借定锟斤拷某锟斤拷锟斤拷锟斤拷 1 锟斤拷值锟斤拷锟斤拷 PHP 应锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷目为锟斤拷值锟斤拷锟斤拷 PHP_FCGI_CHILDREN锟斤拷锟斤拷 min-procs 为 2锟斤拷PHP_FCGI_CHILDREN 为 16 锟斤拷锟斤拷锟斤拷 32 锟斤拷应锟斤拷锟斤拷锟斤拷锟斤拷
Lighttpd 锟结供一锟斤拷锟斤拷为 spawn-fcgi 锟侥筹拷锟斤拷锟斤拷锟津化诧拷锟斤拷 fastcgi 锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷
锟叫匡拷锟杰诧拷通锟斤拷 spawn-fcgi 锟斤拷锟斤拷锟斤拷锟斤拷锟教o拷锟斤拷锟斤拷要锟斤拷些锟斤拷锟斤拷锟斤拷锟借定 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"
Fastcgi 实锟斤拷锟缴憋拷锟斤拷锟斤拷锟节讹拷锟皆讹拷袒锟斤拷锟斤拷苑锟缴⒂︼拷贸锟斤拷锟�
Example #3 锟斤拷锟斤拷远锟斤拷 php-fastcgi 实锟斤拷
fastcgi.server = ( ".php" => (( "host" => "10.0.0.2", "port" => 1030 ), ( "host" => "10.0.0.3", "port" => 1030 )) )