zoukankan      html  css  js  c++  java
  • 《嵌入式web服务器 — CGIC移植(二)》

    1. 下载CGIC源码

      直接百度Github,然后查找CGIC。

      

    2. 配置编译

    2.1 配置编译器

    vi Makefile
    

      

       可以看到默认的编译器是GCC。因为我是直接在虚拟机上面做测试。因此直接用GCC就可以。

      如果是要放在开发板上面,需进行对应的修改。

    CC=arm-linux-gcc
    
    AR=arm-linux-ar
    
    RANLIB=arm-linux-ranlib
    
    CFLAGS=-g -Wall -static
    
     cgictest.cgi: cgictest.o libcgic.a
    
          $(CC) $(CFLAGS) cgictest.o -o cgictest.cgi ${LIBS}
    
     capture: capture.o libcgic.a
    
          $(CC) $(CFLAGS) capture.o -o capture ${LIBS}
    

    2.2 编译

    make
    

      编译生成后在当前目录生成:

           libcgic.a:CGIC库

           capture:调试辅助程序

           cgictest.cgi:测试程序

    2.3 安装CGIC

    make install

     

     CGIC安装路径为

        libcgic.a 安装在/usr/local/lib

        cgic.h 安装在/usr/local/include

        CGIC库安装后就可以使用CGIC编程了

    2.4 CGIC文件移植

      将capture和cgictest.cgi拷贝到开发板的/var/www/cgi-bin目录

    3. 运行测试CGI程序

    3.1 本地测试

    localhost/cgi-bin/cgictest.cgi
    

       

       注意:前提要开启boa服务

    3.2 局域网测试

    ifconfig
    

      

    3. 问题解决

     html网页可以运行,CGI程序运行报错

        Boa服务器报错:cgi_header: unable to find LFLF

        客户端浏览器报错:502 Bad Gateway

                                         The CGI was not CGI/1.1 compliant.

        解决方法:静态编译cgi程序

        arm-linux-gcc -o hello.cgi hello.c -static

     或者是把cgi-bin这个文件夹和对应要执行的cgi应用程序chmod 777

  • 相关阅读:
    Leetcode 538. Convert BST to Greater Tree
    Leetcode 530. Minimum Absolute Difference in BST
    Leetcode 501. Find Mode in Binary Search Tree
    Leetcode 437. Path Sum III
    Leetcode 404. Sum of Left Leaves
    Leetcode 257. Binary Tree Paths
    Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
    Leetcode 226. Invert Binary Tree
    Leetcode 112. Path Sum
    Leetcode 111. Minimum Depth of Binary Tree
  • 原文地址:https://www.cnblogs.com/zhuangquan/p/13041969.html
Copyright © 2011-2022 走看看