精華區beta NTUNIC 關於我們 聯絡資訊
作者 Ptt (錯) 看板 Studyhard 標題 網路CGI教學.....<第一章 Hello world> 時間 Thu Nov 21 13:46:47 1996 ─────────────────────────────────────── 嗯Ptt剛考完... 開個小小的課 條件: 1.會C語言 2.最好先有寫過html的人 3.有工作站帳號 第一步: >pico hello.c 到系上工作站或 ptt server上鍵入以下程式 #include <stdio.h> int main(int argc,char *argv[]) { printf("Content-type:text/html\n\n"); printf("<head>"); printf("<title>Hello world it is cgi test</title>\n"); printf("</head>\n"); printf("<body>\n"); printf("<h1>Hello world </h1>\n"); printf("</body>\n"); return 0; } 第二步. 建立執行檔 >gcc hello.c -o hello.cgi 第三步. 放到www的目錄 在ptt server或計中server是public_html/ 在資訊系上是htdocs/ 沒有的人要先建立一個 (以下以ptt server為例) >mkdir public_html >chmod 755 public_html (讓別人可以使用) >mv hello.cgi public_html/ 第四步. windows下開netscape看 或者使用lynx http://ptt.m8.ntu.edu.tw/~ptt/hello.cgi ~~~~~~~~~~~~~~~~~server ip or domain name ~~~ user id 如此若看到就代表成功囉...