ubuntuの下でC言語を使ってcgiプログラムを開発します
1722 ワード
主な手順は次のとおりです.
1.Cプログラムの開発(標準出力でHTML文字列を出力)
2.apache 2のcgi-binディレクトリにコピー
3.httpd.confでcgi機能をオンにします(私は使っていないようですが、cgiも使えます)
ubuntu上apacheのcgi-binディレクトリは/usr/lib/cgi-bin
hello.c
1.Cプログラムの開発(標準出力でHTML文字列を出力)
2.apache 2のcgi-binディレクトリにコピー
3.httpd.confでcgi機能をオンにします(私は使っていないようですが、cgiも使えます)
ubuntu上apacheのcgi-binディレクトリは/usr/lib/cgi-bin
gcc -o hello hello.c
cp hello /usr/lib/cgi-bin
hello.c
#include <stdio.h>
int main()
{
printf("Content-type:text/html
");
printf("<html>
");
printf("<head><title>welcome to c cgi.</title></head>
<body>");
printf("hello,world!");
printf("</body></html>
");
return 0;
}