首先将lighttpd配置好
然后修改一下配置文件
点击(此处)折叠或打开
- server.modules = (
- "mod_access",
- "mod_cgi",
- "mod_accesslog" )
- server.document-root = "/www/pages/"
- server.errorlog = "/www/logs/lighttpd.error.log"
- index-file.names = ( "index.php", "index.html",
- "index.htm", "default.htm" )
- mimetype.assign = (
- ".pdf" => "application/pdf",
- ".sig" => "application/pgp-signature",
- ".spl" => "application/futuresplash",
- ".class" => "application/octet-stream",
- ".ps" => "application/postscript",
- ".torrent" => "application/x-bittorrent",
- ".dvi" => "application/x-dvi",
- ".gz" => "application/x-gzip",
- ".pac" => "application/x-ns-proxy-autoconfig",
- ".swf" => "application/x-shockwave-flash",
- ".tar.gz" => "application/x-tgz",
- ".tgz" => "application/x-tgz",
- ".tar" => "application/x-tar",
- ".zip" => "application/zip",
- ".mp3" => "audio/mpeg",
- ".m3u" => "audio/x-mpegurl",
- ".wma" => "audio/x-ms-wma",
- ".wax" => "audio/x-ms-wax",
- ".ogg" => "application/ogg",
- ".wav" => "audio/x-wav",
- ".gif" => "image/gif",
- ".jpg" => "image/jpeg",
- ".jpeg" => "image/jpeg",
- ".png" => "image/png",
- ".xbm" => "image/x-xbitmap",
- ".xpm" => "image/x-xpixmap",
- ".xwd" => "image/x-xwindowdump",
- ".css" => "text/css",
- ".html" => "text/html",
- ".htm" => "text/html",
- ".js" => "text/javascript",
- ".asc" => "text/plain",
- ".c" => "text/plain",
- ".cpp" => "text/plain",
- ".log" => "text/plain",
- ".conf" => "text/plain",
- ".text" => "text/plain",
- ".txt" => "text/plain",
- ".dtd" => "text/xml",
- ".xml" => "text/xml",
- ".mpeg" => "video/mpeg",
- ".mpg" => "video/mpeg",
- ".mov" => "video/quicktime",
- ".qt" => "video/quicktime",
- ".avi" => "video/x-msvideo",
- ".asf" => "video/x-ms-asf",
- ".asx" => "video/x-ms-asf",
- ".wmv" => "video/x-ms-wmv",
- ".bz2" => "application/x-bzip",
- ".tbz" => "application/x-bzip-compressed-tar",
- ".tar.bz2" => "application/x-bzip-compressed-tar"
- )
- accesslog.filename = "/www/logs/access.log"
- url.access-deny = ( "~", ".inc" )
- cgi.assign = (
- ".cgi" =>"")
点击(此处)折叠或打开
- #include <stdio.h>
- #include <stdlib.h>
- int main(void)
- {
- char *data;
- long m,n;
- int len = 0;
- char execname[512];
- char argvs[512];
- char *request_method;
- char *client_ip;
- char *content_type;
- memset(execname, 0, 512);
- memset(argvs, 0, 512);
- printf("%s\n\n","Content-Type:text/html;charset=gb2312");
- printf("
multi "); - printf("
multi total
"); - content_type = getenv("CONTENT_TYPE");
- fprintf(stdout, "%s\n", content_type);
- client_ip = getenv("REMOTE_ADDR");
- fprintf(stdout, "|%s|\n", client_ip);
- request_method = getenv("REQUEST_METHOD");
- fprintf(stdout, "|%s|\n", request_method);
- if ( !strncasecmp(request_method, "POST", 4) ) {
- data = getenv("CONTENT_LENGTH");
- len = atoi(data);
- } else {
- data = getenv("QUERY_STRING");
- strncpy(execname, data, strlen(data));
- }
- fgets(execname, len + 1, stdin);
- fprintf(stdout, "|%s|\n", execname);
- if(data == NULL)
- printf("
error no data"
); - return 0;
- }
编译以后执行,使用GET或者POST都可以
点击(此处)折叠或打开
- <html>
- <body>
- <form name="form1" ACTION="/test.cgi" method=post >
- <P>this is a page<BR>
- srcname: <INPUT NAME="srcname" SIZE="5"><BR><BR>
- destname: <INPUT NAME="destname" SIZE="5"><BR><BR>
- dest codec: <INPUT NAME="mpeg4" SIZE="5"><BR><BR>
- <INPUT TYPE="SUBMIT" values="test">
- </form>
- </body>
- </html>
这样就可以了,输入以后,会在页面里打印出来