fastcgi

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 服务器 没有评论

给ubuntu9.10的fastcgi方式的php增加eaccelerator0.9.6加速

1 安装编译环境

root@njava:~# sudo apt-get install build-essential php5-dev

2 安装eaccelerator

root@njava:~# axel http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2
root@njava:~# tar -xjvf eaccelerator-0.9.6.tar.bz2
root@njava:~#cd eaccelerator-0.9.6.tar.bz2
root@njava:~#sudo /usr/bin/phpize
root@njava:~/eaccelerator-0.9.6# ./configure -enable-eaccelerator=shared -with-php-config=/usr/bin/php-config
root@njava:~/eaccelerator-0.9.6# make
root@njava:~/eaccelerator-0.9.6# make install
Installing shared extensions:     /usr/lib/php5/20060613+lfs/
root@njava:~/eaccelerator-0.9.6# mkdir /tmp/eaccelerator
root@njava:~/eaccelerator-0.9.6# chmod 777 /tmp/eaccelerator/
root@njava:~/eaccelerator-0.9.6# vi /etc/php5/conf.d/eaccelerator
[eaccelerator]
zend_extension="/usr/lib/php5/20060613+lfs/eaccelerator.so"
#extension="eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

Tags: , ,

星期日, 21 3 月, 2010 Web 没有评论
1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr