簡體   English   中英

如何運行cgi程序

[英]how to run a cgi program

我是cgi的新手,用一個例子我用c ++寫了一個小程序,我編譯成.cgi文件。

我的問題是:我需要一個單獨的Web服務器嗎? 我有lighttpd作為我的默認網絡服務器...如果我可以運行思想li​​ghttpd請解釋我該怎么做...

  1. 確保您的.cgi文件是可執行文件,並將其放在您的Web根目錄下。
  2. 打開cgi http://redmine.lighttpd.net/wiki/1/Docs:ModCGI
  3. 轉到頁面。 :)

嚴格來說,您不需要服務器。 如果你只是想看看你的CGI正在運行,你可以使用我的小runCGI項目。

您只需要設置一個類似於此的yaml文件

_exec: /var/cgi-bin/myfile.cgi
method: GET
query_string:
  q: s

然后跑

./runCGI myyamlfile.yaml

您將在控制台的標准輸出上看到輸出。

您甚至可以使用gdb調試它,調試runCGI gdb runCGI ,使用正確的參數run someyaml.yamlrun someyaml.yaml ),發出tcatch exectcatch僅捕獲一次),然后將斷點設置為您的CGI文件:

$ g++ a.cc -o a.out
$ cat a.yaml
method: GET
_exec: a.out
$ gdb runCGI
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb) tcatch exec
Catchpoint 1 (exec)
(gdb) run a.yaml
Starting program: /home/elazar/runCGI/runCGI a.yaml
Executing new program: /home/elazar/runCGI/a.out
0x00007fc3a24a6a60 in ?? () from /lib64/ld-linux-x86-64.so.2
(gdb) tbreak main
Breakpoint 2 at 0x400577: file a.cc, line 2.
(gdb) c
Continuing.
main (argc=1, argv=0x7fff14891408) at a.cc:2
2       int a =0;
(gdb)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM