fastcgi Linux环境下的安装

来源:互联网 发布:sql%rowcount 编辑:程序博客网 时间:2024/05/23 15:38

 

1.关于fastcgi的介绍

    转自http://www.bsdmap.com/UNIX_html/linux_Tutorial2/cdmag/2709.html

FastCGI
http://www.fastcgi.com/
  CGICommonGatewayInterface的缩写。它的存在使得避免针对不同WebServerAPI发展不同的程式成为可能。软体发展者可以用各种语言撰写程式作为W3Server与其他各种不同的伺服器间沟通的桥梁。在第五届国际WWW会议中,OpenMarket这家公司发表了一篇论文,标题是“FastCGI:AHigh-PerformanceGatewayInterface”。文中提出了对於现有CGI规格的改进与功能的增强。现有的CGI规格具有如下的特点:

●开放标准
●简单易了解
●适合各种程式语言
●与机器软硬体架构无关
●与Server的程序(process)无关

  而CGI的缺点在於执行的速度不够快(相较於ServerAPI写的程式)。而且CGI所扮演的角色也局限於反应者(responder)的角色。FastCGI除了具有CGI所具有的优点外,并且也大幅改进执行的速度。此外最大的特点还有一个,就是它也使得分散执行应用程式成为可能的事情。目前可以发展FastCGI的Server有OpenMarket自己出的SecureWebServer,NCSAHTTPD1.5.1,还有上面提到的ApacheHTTPServer。Apache用的FastCGImodule可以在 http://www.fastcgi.com/servers/apache/连同说明文件一起取得。

2.fastcgi的安装

从官方站点可以下到最新的fastcgi.tar.gz的包,将包解包。

#tar -xvzf fastcgi.tar.gz

#cd fastcgi

#./configure

#make

#make install

3.fastcgi的配置

默认情况下库文件是安装到/usr/local/lib下的

cd /etc/ld.so.config.d

vi fcgi.config

在该文件中增加/usr/local/lib

4.测试小例子

来段官方的小例子

    #include "fcgi_stdio.h"
    #include <stdlib.h>

    void main(void)
    {
        int count = 0;
        while(FCGI_Accept() >= 0)
            printf("Content-type: text/html/r/n"
                   "/r/n"
                   "<title>FastCGI Hello!</title>"
                   "<h1>FastCGI Hello!</h1>"
                   "Request number %d running on host <i>%s</i>/n",
                    ++count, getenv("SERVER_NAME"));
    }

g++ -o hello hello.cpp -lfcgi

编译后放到/var/www/cgi-bin下

chmod 700 hello

启动apache server

service httpd start

看一下效果,基本就可以用了:)

 

原创粉丝点击