php fastcgi,配置apache以fastcgi运行php

17270ce95af85a4a2d33846cd5831d99.png

apache默认是用自带的mod_php模块运行php,现在我们介绍使用fastcgi来执行php脚本。先说下fastcgi的优点:

Fastcgi的优点:

从稳定性上看, fastcgi是以独立的进程池运行来cgi,单独一个进程死掉,系统可以很轻易的丢弃,然后重新分 配新的进程来运行逻辑.

· 从安全性上看,Fastcgi支持分布式运算. fastcgi和宿主的server完全独立, fastcgi怎么down也不会把server搞垮.

· 从性能上看, fastcgi把动态逻辑的处理从server中分离出来, 大负荷的IO处理还是留给宿主server, 这样宿主server可以一心一意作IO,对于一个普通的动态网页来说, 逻辑处理可能只有一小部分, 大量的图片等静态

IO处理完全不需要逻辑程序的参与.

· 从扩展性上讲, fastcgi是一个中立的技术标准, 完全可以支持任何语言写的处理程序 (php,java,perl,ruby,c++,python…)

· 适用操作系统,可在任何平台上http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz使用

安装apache

wget http://apache.ziply.com//httpd/httpd-2.2.21.tar.gz

tar xzf httpd-2.2.21.tar.gz

cd httpd-2.2.21

./configure --prefix=/usr/local/apache

make && make install

安装fastcgi

wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz

tar xzf mod_fastcgi-2.4.6.tar.gz

cd mod_fastcgi-2.4.6

cp Makefile.AP2 Makefile

make top_dir=/usr/local/apache

make top_dir=/usr/local/apache install

完成之后编辑httpd.conf配置文件,加入fastcgi模块装载代码:

LoadModule fastcgi_module modules/mod_fastcgi.so

安装php5.2

wget http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror

tar xzf php-5.2.17.tar.gz

cd php-5.2.17

./configure --prefix=/usr/local/php --enable-fastcgi --disable-cli

make && make install

配置apache支持php

编辑httpd.conf文件,加入如下代码:

### fastcgi ###

ScriptAlias /fcgi-bin/ "/usr/local/php/bin/"

AddHandler php-fastcgi .php

Action php-fastcgi /fcgi-bin/php-cgi

AddType application/x-httpd-php .php

AddHandler fcgid-script. .php .fcgi   ### 暂时只配置支持.php

IdleTimeout 300

ProcessLifeTime 1800

MaxProcessCount 100

DefaultMinClassProcessCount 3

DefaultMaxClassProcessCount 8

IPCConnectTimeout 15

IPCCommTimeout 300

MaxRequestsPerProcess 100

### fastcgi ###

建立虚拟主机可以这样配置:

DocumentRoot /usr/local/apache/htdocs

ServerName localhost

Options +ExecCGI

AddHandler fastcgi-script .fcgi

AddType application/x-httpd-php .php

Action application/x-httpd-php /fcgi-bin/php-cgi

Options Indexes ExecCGI

Order allow,deny

allow from all

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值