zoukankan      html  css  js  c++  java
  • fastcgi(一)

    首先安装 fastcgi 开发包 ...

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

    #tar -zxvf fcgi-current.tar.gz

    #cd fcgi-2.4.0

    #./configure --prefix=/usr/local/fastcgi/

    #make && make install


    写一个简单的fcgi 程序

    #vim hello.c 

    内容如下:

    1. #include </usr/local/fastcgi/include/fcgi_stdio.h>  
    2.   
    3. int main(void){  
    4.     while( FCGI_Accept() >= 0){  
    5.         printf( "Content-Type: text/html " );  
    6.         printf(" ");  
    7.         printf( "Hello world in C " );  
    8.     }  
    9. }  

    #gcc -o hello.fcgi hello.c -L /usr/local/fastcgi/lib/ -lfcgi


    [root@lxp2 Downloads]# tar -xf nginx-1.0.10.tar.gz 
    [root@lxp2 Downloads]# cd nginx-1.0.10
    [root@lxp2 nginx-1.0.10]# ./configure 

    checking for PCRE library ... not found
    checking for PCRE library in /usr/local/ ... not found
    checking for PCRE library in /usr/include/pcre/ ... not found
    checking for PCRE library in /usr/pkg/ ... not found
    checking for PCRE library in /opt/local/ ... not found


    ./configure: error: the HTTP rewrite module requires the PCRE library.
    You can either disable the module by using --without-http_rewrite_module
    option, or install the PCRE library into the system, or build the PCRE library
    statically from the source with nginx by using --with-pcre=<path> option.

    这说明系统中缺少PCRE库。该库是实现正则表达式的基础,如果缺少此库,nginx无法支持HTTP中的URL重写功能。如果你不需要此功能,可以在执行编译配置脚本时加入“--without-http_rewrite_module”。但是,这里我们需要这项功能。于是下载PCRE库。

     

    2.下载安装PCRE库:

    PCRE库是实现Perl式正则表达式的基础。如果系统中缺少此库需要编译安装。可以从著名的开源软件网站sourceforge上下载:http://sourceforge.net/projects/pcre/files/pcre/。目前最新版本是8.20。

    仍然是下载后解压、配置、编译和安装:

      nginx path prefix: "/usr/local/nginx"
      nginx binary file: "/usr/local/nginx/sbin/nginx"
      nginx configuration prefix: "/usr/local/nginx/conf"
      nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
      nginx pid file: "/usr/local/nginx/logs/nginx.pid"
      nginx error log file: "/usr/local/nginx/logs/error.log"
      nginx http access log file: "/usr/local/nginx/logs/access.log"
      nginx http client request body temporary files: "client_body_temp"
      nginx http proxy temporary files: "proxy_temp"
      nginx http fastcgi temporary files: "fastcgi_temp"
      nginx http uwsgi temporary files: "uwsgi_temp"
      nginx http scgi temporary files: "scgi_temp"
    [root@lxp2 nginx-1.0.10]# make


    [root@lxp2 nginx-1.0.10]# sudo make install 





    nginx.conf的配置要修改

    1. server {  
    2.     listen 80;  
    3.     location ~ .fcgi$ {  
    4.             root           /srv/www;  
    5.             fastcgi_pass   127.0.0.1:9002;  
    6.             include        fastcgi_params;  
    7.     }  
    8. }  

    重启nginx ,然后用fastcgi 启动程序,同时监听 9002 端口

    # /usr/local/fastcgi/bin/cgi-fcgi -start -connect 127.0.0.1:9002 /srv/html/cgi/hello.fcgi




  • 相关阅读:
    POJ 1936 All in All
    POJ 2305 Basic remains
    POJ 2081 Recaman's Sequence
    MFC MDI 窗口函数执行顺序
    decompose
    不新建一个文档
    code mistake
    ...
    paper
    stereo
  • 原文地址:https://www.cnblogs.com/nktblog/p/4027151.html
Copyright © 2011-2022 走看看