- 积分
- 121
- 威望
-
- 金钱
-
- 注册时间
- 2010-7-2
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
spawn-fcgi1.概况spawn-fcgi官方:http://redmine.lighttpd.net/projects/spawn-fcgi/wiki,可以从这里下载到最新稳定版本。
lighttpd官方:http://www.lighttpd.net/
其实spawn-fcgi是lighttpd的一个分支项目,是一个cgi进程的管理器,效率不错。
2.安装3.配置这里主要整理spawn-fcgi相关配置!
安装好后,可以通过:spawn-fcgi -h
Usage: spawn-fcgi [options] [-- <fcgiapp> [fcgi app arguments]]
spawn-fcgi v1.6.2 (ipv6) - spawns FastCGI processes
Options:
-f <path> filename of the fcgi-application (ignored if <fcgiapp> is given)
-d <directory> chdir to directory before spawning
-a <address> bind to IPv4/IPv6 address (defaults to 0.0.0.0)
-p <port> bind to TCP-port
-s <path> bind to Unix domain socket
-M <mode> change Unix domain socket mode
-C <children> (PHP only) numbers of childs to spawn (default: not setting
the PHP_FCGI_CHILDREN environment variable - PHP defaults to 0)
-F <children> number of children to fork (default 1)
-P <path> name of PID-file for spawned process (ignored in no-fork mode)
-n no fork (for daemontools)
-v show version
-?, -h show this help
(root only)
-c <directory> chroot to directory
-S create socket before chroot() (default is to create the socket in the chroot)
-u <user> change to user-id
-g <group> change to group-id (default: primary group of user if -u is given)
-U <user> change Unix domain socket owner to user-id
-G <group> change Unix domain socket group to group-id
看到详细的参数说明,不过这里为了方便,还是喜欢通过这个spawn-php.sh来管理php-cgi比较方便^_^
有个地方需要注意:spawn-php.sh这个文件有个bug,见下面红色字体部分:
# cat spawn-php.sh
#!/bin/bash
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI=”/usr/local/bin/spawn-fcgi“
## ABSOLUTE path to the PHP binary
FCGIPROGRAM=”/usr/local/php/sbin/php-cgi“
## TCP port to which to bind on localhost
FCGIPORT=”9002″
## number of PHP children to spawn
PHP_FCGI_CHILDREN=10
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=1000
## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS=”192.168.0.254“
pripath=”/home/wwwroot”
# allowed environment variables, separated by spaces
ALLOWED_ENV=”pripath"
PATH USER”
## if this script is run as root, switch to the following user
USERID=nobody
GROUPID=nobody
################## no config below this line
if test x$PHP_FCGI_CHILDREN = x; then
PHP_FCGI_CHILDREN=5
fi
export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
ALLOWED_ENV=”$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS”
if test x$UID = x0; then
EX=”$SPAWNFCGI -a $FCGI_WEB_SERVER_ADDRS -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN”
else
EX=”$SPAWNFCGI -a $FCGI_WEB_SERVER_ADDRS -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN”
fi
# copy the allowed environment variables
E=
for i in $ALLOWED_ENV; do
E=”$E $i=${!i}”
done
# clean the environment and set up a new one
env - $E $EX
以上红色部分是要自己补上去,不然默认监听在0.0.0.0,绿色字体部分是要根据具体情况做相应的修改!蓝色字体部分是根据自己的需求加的参数,意思是:php的代码放在pripath这个变量所在的目录下,这个是为了跨机器执行php-cgi,这样可以通过proxy来调用,可以提升cpu利用率(将php-cgi进程跑在cpu消耗低的机器上)
[ 本帖最后由 hackin 于 2010-7-17 23:01 编辑 ] |
|