为extmail增加FCGI的支持,主要是为了获得优异的web效能,克服CGI不能应付大量访问及低效率的缺陷。根据我们的测试,CGI模式下的页面效率只有FCGI下的1/10~1/100,因此建议有条件的用户还是使用FCGI。日后ExtMail Solution的web CGI程序将全部都支持FCGI。

Extmail开发团队花了大量时间重新设计了FCGI server的进程管理模型,并参考了apache的机制,新版dispatch.fcgi 终于可以象apache一样定义max server数,min server(启动进程数)以及每进程服务次数,每进程执行时限等,可较好的利用系统cpu/内存资源,既保证不多占内存,又可保证请求数上升时能有足够进程数服务。

就我们搜索发现,目前网上还没有开源版的FastCGI server能实现上述自适应负载功能(例如php-fpm还未实现,POE等也未实现),所以Extmail的dispatch.fcgi也许是第一个实现了这个功能。

mod_fastcgi 是针对Apache Web服务器的FCGI支持模块
下载地址: http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz

安装mod_fastcgi :

shell

# wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
# tar xfz mod_fastcgi-2.4.6.tar.gz
# cd mod_fastcgi-2.4.6
# cp Makefile.AP2 Makefile
# yum install make -y
# yum install httpd-devel -y
# make top_dir=/usr/lib64/httpd/ install

安装perl-FCGI 除了Apache需要FCGI的支持外,extmail也需要相应的perl-FCGI模块。

shell

# yum install perl-FCGI

配置虚拟主机:

shell

# vi /etc/httpd/conf/vhost_extmail.conf

 

 

 
    
  1. #增加内容如下
  2. LoadModule fastcgi_module modules/mod_fastcgi.so 
  3.  
  4. <Ifmodule mod_fastcgi.c> 
  5. FastCgiExternalServer /usr/bin/dispatch.fcgi -host 127.0.0.1:8888 -idle-timeout 240 
  6. </Ifmodule> 
  7.  
  8. #同时,去掉如下行: 
  9. #ScriptAlias /extmail/cgi/ /var/www/extsuite/extmail/cgi/  
  10.  
  11. #在去掉之行下方添加: 
  12. Alias /extmail/cgi/ /usr/bin/dispatch.fcgi/ 
  13. <Location "/extmail/cgi"> 
  14. SetHandler fastcgi-script 
  15. </Location> 

重启Apache和fastcgi server开机自启动:

shell

# service httpd restart
# /var/www/extsuite/extmail/dispatch-init start
# echo '/var/www/extsuite/extmail/dispatch-init start' >> /etc/rc.d/rc.local