FastCGI服务器的安装和使用(spawn-fcgi和php-fpm)

zenwong 2010-02-16 10:04:26
原地址:
http://doc.zenw.org/developer/ch02.html
http://doc.zenw.org/developer/ch02s02.html




FastCGI 像是一个常驻 (long-live) 型的 CGI,它可以一直执行着,只要激活后,不会每次都要花费时间去 fork 一次 (这是 CGI 最为人诟病的 fork-and-execute 模式)。



spawn-fcgi


spawn-fcgi是一个通用的FastCGI管理服务器

她是lighttpd中的一部份,但目前已经单独成为一个项目,最新的lighttpd没有这一块,但可以在以前版本中找到她

在lighttpd-1.4.15( http://www.lighttpd.net/download/lighttpd-1.4.15.tar.gz )中就有她

Note注:最新的spawn-fcgi可以到lighttpd.net网站搜索“spawn-fcgi”找到她的最新版本发布地址

目前她的下载地址是http://redmine.lighttpd.net/news/2 最新版本是http://www.lighttpd.net/download/spawn-fcgi-1.6.0.tar.gz



tar -zxvf lighttpd-1.4.15.tar.gz
cd lighttpd-1.4.15
./configure #编译
make #因为我不需要安装lighttp而是只需要他其中的某个文件,所以只make就可以了,不需要make install
cp src/spawn-fcgi /usr/local/bin/spawn-fcgi #取出spawn-fcgi的程序


下面我们就可以使用 spawn-fcgi 来控制php-cgi的FastCGI进程了

/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php-cgi


参数含义如下

-f <fcgiapp> 指定调用FastCGI的进程的执行程序位置,根据系统上所装的PHP的情况具体设置
-a <addr> 绑定到地址addr
-p <port> 绑定到端口port
-s <path> 绑定到unix socket的路径path
-C <childs> 指定产生的FastCGI的进程数,默认为5(仅用于PHP)
-P <path> 指定产生的进程的PID文件路径
-u和-g FastCGI使用什么身份(-u 用户 -g 用户组)运行,Ubuntu下可以使用www-data,其他的根据情况配置,如nobody、apache等


php-fpm

她同样也是一个PHP FastCGI管理服务器,是只用于PHP的

可以在 http://php-fpm.org/download 下载得到

她是PHP源代码的一个补丁,必须将她patch到你的PHP源代码中,在编译安装PHP后才可以使用


安装方法类似:

tar zxvf php-5.2.10.tar.gz

gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1

cd php-5.2.10/

./configure --prefix=/usr/local/webserver/php \
--with-config-file-path=/usr/local/webserver/php/etc \
--with-mysql=/usr/local/webserver/mysql \
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config \
--with-iconv-dir=/usr/local \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-discard-path \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fastcgi \
--enable-fpm \
--enable-force-cgi-redirect \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear

make ZEND_EXTRA_LIBS='-liconv'
make install

cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../





更多内容可访问:
http://www.zenw.org
http://doc.zenw.org
http://doc.zenw.org/linux
http://doc.zenw.org/mysql
http://doc.zenw.org/developer
...全文
1209 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ciahi 2010-03-05
  • 打赏
  • 举报
回复
Mark一下~~~~~~
sciolist 2010-02-26
  • 打赏
  • 举报
回复
学习,很有用的知识.
zenwong 2010-02-17
  • 打赏
  • 举报
回复
不好意思,雷到你了,呵呵
cs5276 2010-02-17
  • 打赏
  • 举报
回复
。。。。
街头小贩 2010-02-17
  • 打赏
  • 举报
回复
新手学习

2,204

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧