【求助】Linux&CGI



贊助商連結


jackiemi2
2003-03-28, 05:35 PM
請教各位大大!
小弟在RH Linux上架了一個web server(Apache or Thttpd), 想用C去寫寫CGI, web server架起來是沒問題, 但在CGI這一段卻怎麼也無法在client端的browser上show的出資料, 我照RH應用書上的step我的CGI module有載入, 也能將cgi-bin目錄下的option也改成了ExecCGI, 但我試著用C去寫一段小程式只是show一段文字, compiler後用chmod將權限設成755丟到cgi-bin目錄中, 但回傳卻是
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: mult.cgi

好像無法判別我寫的是段CGI的程式, 不知那個大大曾寫過CGI的, 指教一下小弟我..感謝您謝謝您!

一個頭快想破的人

贊助商連結


repsol
2003-03-28, 05:55 PM
可以將程式的內容貼上來看看嗎??
當然是 compile 前的原始碼囉..

jackiemi2
2003-04-08, 11:55 AM
最初由 repsol 發表
可以將程式的內容貼上來看看嗎??
當然是 compile 前的原始碼囉..
大大們!

#include <stdio.h>

int
main( int argc, char** argv )
{
fputs( "Content-type: text/plain\n\nHello.\n", stdout );
exit( 0 );
}
小弟用這段程式, 只是簡單的印出一段文字出來, 我用的compiler指令如下:
gcc -O mult.c -s -o mult.cgi
compiler出來mult.cgi的檔後我用chmod 755 mult.cgi去改權限
現在的問題是能找到那個cgi-bin的目錄及程式, 但回傳後的Hello是無法show出來, 我只能看到空白的網頁, 我有去看一下cgi回傳網頁的程式, 裡面也是空白的沒有任何資料, 請問各位大大, 我是那個地方出了問題...謝謝各位的指導小弟感激不盡!

repsol
2003-04-08, 12:27 PM
檢查一下 httpd.conf
有關 AddHandler 的設定

The above directive tells Apache to permit the execution of CGI files. You will also need to tell the server what files are CGI files. The following AddHandler directive tells the server to treat all files with the cgi or pl extension as CGI programs:

AddHandler cgi-script cgi pl