Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2354442
  • 博文数量: 141
  • 博客积分: 3552
  • 博客等级: 中校
  • 技术积分: 4148
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-15 14:39
个人简介

熟悉Linux下程序设计及各种应用程序 熟悉C Language 熟悉Glusterfs、FFmpeg、CDN 系统设计,计算机图形系统设计、分布式程序设计 目前主要研究方向:流媒体

文章分类

全部博文(141)

分类: LINUX

2012-03-22 14:28:49

做法比较简单
首先将lighttpd配置好
然后修改一下配置文件

点击(此处)折叠或打开

  1. server.modules = (
  2. "mod_access",
  3. "mod_cgi",
  4. "mod_accesslog" )

  5. server.document-root = "/www/pages/"
  6. server.errorlog = "/www/logs/lighttpd.error.log"
  7. index-file.names = ( "index.php", "index.html",
  8. "index.htm", "default.htm" )
  9. mimetype.assign = (
  10. ".pdf" => "application/pdf",
  11. ".sig" => "application/pgp-signature",
  12. ".spl" => "application/futuresplash",
  13. ".class" => "application/octet-stream",
  14. ".ps" => "application/postscript",
  15. ".torrent" => "application/x-bittorrent",
  16. ".dvi" => "application/x-dvi",
  17. ".gz" => "application/x-gzip",
  18. ".pac" => "application/x-ns-proxy-autoconfig",
  19. ".swf" => "application/x-shockwave-flash",
  20. ".tar.gz" => "application/x-tgz",
  21. ".tgz" => "application/x-tgz",
  22. ".tar" => "application/x-tar",
  23. ".zip" => "application/zip",
  24. ".mp3" => "audio/mpeg",
  25. ".m3u" => "audio/x-mpegurl",
  26. ".wma" => "audio/x-ms-wma",
  27. ".wax" => "audio/x-ms-wax",
  28. ".ogg" => "application/ogg",
  29. ".wav" => "audio/x-wav",
  30. ".gif" => "image/gif",
  31. ".jpg" => "image/jpeg",
  32. ".jpeg" => "image/jpeg",
  33. ".png" => "image/png",
  34. ".xbm" => "image/x-xbitmap",
  35. ".xpm" => "image/x-xpixmap",
  36. ".xwd" => "image/x-xwindowdump",
  37. ".css" => "text/css",
  38. ".html" => "text/html",
  39. ".htm" => "text/html",
  40. ".js" => "text/javascript",
  41. ".asc" => "text/plain",
  42. ".c" => "text/plain",
  43. ".cpp" => "text/plain",
  44. ".log" => "text/plain",
  45. ".conf" => "text/plain",
  46. ".text" => "text/plain",
  47. ".txt" => "text/plain",
  48. ".dtd" => "text/xml",
  49. ".xml" => "text/xml",
  50. ".mpeg" => "video/mpeg",
  51. ".mpg" => "video/mpeg",
  52. ".mov" => "video/quicktime",
  53. ".qt" => "video/quicktime",
  54. ".avi" => "video/x-msvideo",
  55. ".asf" => "video/x-ms-asf",
  56. ".asx" => "video/x-ms-asf",
  57. ".wmv" => "video/x-ms-wmv",
  58. ".bz2" => "application/x-bzip",
  59. ".tbz" => "application/x-bzip-compressed-tar",
  60. ".tar.bz2" => "application/x-bzip-compressed-tar"
  61. )

  62. accesslog.filename = "/www/logs/access.log"
  63. url.access-deny = ( "~", ".inc" )
  64. cgi.assign = (
  65. ".cgi" =>"")
然后在目录下编译一个cgi执行文件就可以了

点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <stdlib.h>

  3. int main(void)
  4. {
  5.     char *data;
  6.     long m,n;
  7.         int len = 0;
  8.         char execname[512];
  9.         char argvs[512];
  10.         char *request_method;
  11.         char *client_ip;
  12.         char *content_type;

  13.         memset(execname, 0, 512);
  14.         memset(argvs, 0, 512);

  15.     printf("%s\n\n","Content-Type:text/html;charset=gb2312");
  16.     printf("multi ");
  17.     printf("

    multi total

    "
    );

  18.         content_type = getenv("CONTENT_TYPE");
  19.         fprintf(stdout, "%s\n", content_type);
  20.         client_ip = getenv("REMOTE_ADDR");
  21.         fprintf(stdout, "|%s|\n", client_ip);
  22.         request_method = getenv("REQUEST_METHOD");
  23.         fprintf(stdout, "|%s|\n", request_method);
  24.         if ( !strncasecmp(request_method, "POST", 4) ) {
  25.                 data = getenv("CONTENT_LENGTH");
  26.                 len = atoi(data);
  27.         } else {
  28.         data = getenv("QUERY_STRING");
  29.                 strncpy(execname, data, strlen(data));
  30.         }
  31.         fgets(execname, len + 1, stdin);
  32.         fprintf(stdout, "|%s|\n", execname);
  33.     if(data == NULL)
  34.         printf("

    error no data");


  35.     return 0;
  36. }

编译以后执行,使用GET或者POST都可以


点击(此处)折叠或打开

  1. <html>

  2.     <body>

  3.         <form name="form1" ACTION="/test.cgi" method=post >
  4.             <P>this is a page<BR>
  5.             srcname: <INPUT NAME="srcname" SIZE="5"><BR><BR>
  6.             destname: <INPUT NAME="destname" SIZE="5"><BR><BR>
  7.             dest codec: <INPUT NAME="mpeg4" SIZE="5"><BR><BR>
  8.             <INPUT TYPE="SUBMIT" values="test">
  9.         </form>

  10.     </body>

  11. </html>

这样就可以了,输入以后,会在页面里打印出来

阅读(7380) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~