zoukankan      html  css  js  c++  java
  • 【五】安装fcig

    安装fcig

    此步骤是为了让spawn-fcgi能够识别自定义的demo

    • 下载fcgi:wget ftp://ftp.ru.debian.org/gentoo-distfiles/distfiles/fcgi-2.4.1-SNAP-0910052249.tar.gz

    • 解压安装包:tar -xvf fcgi-2.4.1-SNAP-0910052249.tar.gz

    • 修改文件

      1. find . -name fcgio.h
      2. vim ./include/fcgio.h
      3. 在头部添加代码:#include <cstdio>

    编译文件

    fcgi-2.4.1-SNAP-0910052249目录下执行:./configure

    然后顺序执行命令:makemake install

    自定义c文件

    • 创建一个.c结尾的文件,代码如下
    #include <iostream>
    #include <string>
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <fcgi_stdio.h>
    
    int main() {
    
        int count = 0;
        while(FCGI_Accept() >= 0) {
            printf("Content-type: text/html
    "
                    "
    "
                    ""
                    "Hello Badou EveryBody!!!"
                    "Request number %d running on host %s "
                    "Process ID: %d
     ", ++count, getenv("SERVER_NAME"), getpid());
        }
        return 0;
    }
    
    • 编译c文件,命令:g++ -g -o test test.c -lfcgi,编译之后会产生同名的编译文件

    • 运行编译文件test可能提示找不到lib库,修改ld.so.conf文件,然后执行命令ldconfig命令

      • 修改文件:vim /etc/ld.so.conf
      include ld.so.conf.d/*.conf
      /usr/include/boost/
      /usr/local/lib/
      
      • 执行命令ldconfig
    • 运行编译后的文件,命令:./test
      打印结果

      Hello Badou EveryBody!!!
      Request number 1 running on host (null) Process ID: 36010
      

    测试成功后,启动spawn cgi进行代理托管

    • 运行命令:/usr/local/src/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 8088 -f /test/thrift_test/cgi_demo/test,之后会提示:spawn-fcgi: child spawned successfully: PID: 36213,然后使用命令:netstat -antup | grep 8088查看端口是否被监听
  • 相关阅读:
    js操作class值
    四、多表连接
    三、约束
    根据出生日期计算年龄
    二、MySql数据操作(二)
    一、MySql基本语句(一)
    jquery基本操作
    纯js实现全选,全不选,反选
    css的基础知识1
    表格的使用
  • 原文地址:https://www.cnblogs.com/screen/p/9481729.html
Copyright © 2011-2022 走看看