Zeus中安装PHP( 二 )


export ZEUSHOME
fi
case "$1" in
"start")
if [ -e $SEMFILE ]
then
echo FastCGI PHP error: already running.Restart FastCGI PHP now
kill `cat $SEMFILE`
sleep 5
fi
if [ ! -x $FPHPBIN ]
then
echo FastCGI PHP error: please check that $FPHPBIN is executable and exists.
exit 1
fi
echo Starting FastCGI PHP.
$ZEUSHOME/web/bin/fcgirunner --user=65534 --group=65534 --pidfile=$SEMFILE 8002 $FPHPBIN

"stop")
if [ -e $SEMFILE ]
then
echo Stopping FastCGI PHP.
kill `cat $SEMFILE`
rm $SEMFILE
exit 0
fi

"restart")
if [ -e $SEMFILE ]
then
echo Stopping FastCGI PHP.
kill `cat $SEMFILE`
sleep 5
fi
echo Starting FastCGI PHP.
$ZEUSHOME/web/bin/fcgirunner --user=65534 --group=65534 --pidfile=$SEMFILE 8002 $FPHPBIN

*)
echo "usage: $0 {start|stop|restart}"

esac
exit 1
在这个脚本中有以下内容需要视系统情况而 修改:【Zeus中安装PHP】FPHPBIN=/usr/local/php/bin/php 应设置为php的路径
SEMFILE=/tmp/php.pid 生成php.pid的路径,该目录必须可写
PHP_FCGI_CHILDREN=100 php进程数目
PHP_FCGI_MAX_REQUESTS=1000 每个php的进程在退出前能够响应的请求数,用于释放资源 上面两个根据硬件配置和网站访问量设置,默认值是8,500 。一般来说 PHP_FCGI_CHILDREN > 访问并发最大值 10
PHP_FCGI_MAX_REQUESTS 如果设置过小,访问量大的网站会因为php进程重起频繁增加负荷 。
#echo 1024 65000 > /proc/sys/net/ipv4/ip_local_port_range 只用于linux
--user=65534 --group=65534 为php进程运行的用户和组,一般设置为nobody用户和组FreeBSD是65534/65534,Linux是99/99
最后,将S05php文件设置为可执行文件,并将FastCGI/PHP运行起来:
chmod 755 S05php
./S05php start 一但启动后就会在ps -ax列表中显示出PHP_FCGI_CHILDREN 1个php进程 。
到你的vhost对应的Docroot目录中建一个info.php文件,内容为: phpinfo();
?> 使用浏览器访问vhost中的info.php文件,应该就可以看到PHP的info页面了 。

附注
感谢CCF的坛主hunreal写出的S05php脚本,它真的非常好用!
如果还有什么想了解的可以到 Zeus PHP支持 页得到更多的信息 。

推荐阅读