CentOS安装Apache的FastCGI模块(mod_fastcgi)

网上有很多篇关于Apache的fastcgi模块安装说明的文章,大部分都是基于Apache源码编译的,如果是通过yum install方式安装httpd的话,直接依葫芦画瓢必然会遇到各种各样的编译问题,通过查阅老外写的一些安装文档,我大致重新整理了一下。

1. 安装编译相关的依赖包

# yum install httpd-devel apr apr-devel libtool

2. 下载mod_fastcgi源代码

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

3. 解压并进行编译安装

# tar zxvf mod_fastcgi-2.4.6.tar.gz
# cd mod_fastcgi-2.4.6
# cp Makefile.AP2 Makefile
# vim Makefile
修改top_dir目录,64位系统的路径为lib64,32位系统的路径为/usr/lib/httpd

top_dir      = /usr/lib64/httpd


保存退出后,开始进行编译安装。
# make
# make install

4. 加载模块

# vim /etc/httpd/conf/httpd.conf
找到LoadModule部分,添加一行加载语句

...

LoadModule fastcgi_module modules/mod_fastcgi.so
...


5. 重启服务

# /etc/init.d/httpd restart

如果能正常启动,则log里面将显示以下信息

# grep -i "FastCGI" /var/log/httpd/error_log

[Mon Jul 29 06:54:27 2013] [notice] FastCGI: process manager initialized (pid 2098)
[Mon Jul 29 06:54:27 2013] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fastcgi/2.4.6 configured -- resuming normal operations


6. 安装FPM(FastCGI进程管理器)

FPM(FastCGI 进程管理器)用于替换 PHP FastCGI 的大部分附加功能,对于高负载网站是非常有用的。
# yum install php-fpm
# /etc/init.d/php-fpm start
# chkconfig php-fpm on
# netstat -anp |grep php
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      2575/php-fpm        
unix  3      [ ]         STREAM     CONNECTED     25812  2575/php-fpm        
unix  3      [ ]         STREAM     CONNECTED     25811  2575/php-fpm        

7. 修改配置

新建一个配置文件/etc/httpd/conf.d/fastcgi.php.conf

DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /var/www/cgi-bin/php5-fcgi
FastCgiExternalServer /var/www/cgi-bin/php5-fcgi -idle-timeout 60 -host 127.0.0.1:9000 -pass-header Authorization

重启Apache和FPM:
# service httpd restart
# service php-fpm restart

测试phpinfo()页面,配置成功则显示为:
...
Server API        FPM/FastCGI
...

参考文章:

http://linuxwave.blogspot.com/2010/08/installing-apache-modfastcgifastcgi.html
http://atoomnet.net/php-fpm-centos-6/

转载于:https://my.oschina.net/alanlqc/blog/148126

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值