nginx 0.8.34以fastcgi方式运行php

1 安装spawn-fcgi

bear@bear-laptop:~$sudo apt-get install php5-cli php5-cgi php5-xcache build-essential
bear@bear-laptop:~$ sudo apt-get install  spawn-fcgi

很多地方都说要先安装lighttpd,不用这样,可以直接安装 spawn-fcgi
2 增加fastcgi控制脚本

bear@bear-laptop:/usr/bin$ sudo vi /etc/init.d/php-fastcgi
#!/bin/bash
SCRIPT=/usr/bin/spawn-fcgi
NAME=php-fastcgi
DESC=Spawn-fcgi

case "$1" in
    start)
	echo -n "Starting $DESC: " 
	$SCRIPT -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/$NAME.pid|| true
	echo "$NAME."
;;
    stop)
      echo -n "Stopping $DESC: "
      killall -9 php5-cgi
      echo "$NAME."
;;
    restart)
       echo -n "Stopping $DESC: "
	killall -9 php5-cgi
	sleep 1
       echo  "Starting $DESC: " 
     	$SCRIPT -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/$NAME.pid|| true
	echo  "$DESC."
;;
*)
      echo "Usage: $NAME {start|stop|restart}"
      exit 1
;;
esac
exit 0

3 开机启动

bear@bear-laptop:/usr/bin$ sudo gedit /etc/rc.local
/etc/init.d/php-fastcgi start

Tags: , , ,

星期一, 22 3 月, 2010 服务器

Leave a Reply

1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr