CGI-BBS > サーバ > Apache > Apache2の設置でC言語によるCGIを実行可能な設定にしたい。


カレッヂ
カレッヂ


質問者 野田  投稿日 7/10(木) 21:43:39
何方か Apache/2.0.40 バージョンでCによるCGIを使用するhttpd.confの設定を御教授ください。
色々と調べ試行錯誤を行って見ました出来ません。どうか宜しくお願いします。

*現状CGIもSSIも正常に動作しています。
環境:Red Hat Linux8 サーバー
     Apache/2.0.40	

テスト(test.c)用ソース
#include <stdio.h>
int main()
	{
	printf("content-type: text/html\n");
	printf("\n");
	printf("<html><body>\n");
	printf("hello world!\n");
	printf("</body></html>\n");
	return 1;
	}

/var/www/cgi-bin ディレクトリにおいてgccでコンパイル後端末エミュレーターより実行しますと。

# ./test.cgi
content-type: text/html

<html><body>
hello world!
</body></html>

Cとしては正常に動作しているように思いますが、

LAN内他のパソコンIE(V6.0.2800)より実行した結果が下記のエラーメッセージです。


エラーメッセージ
Server error!

The server encountered an internal error and was unable to complete your request. 
Error message: 
Unrecognized character \x7F at /var/www/cgi-bin/test.cgi line 1. 
If you think this is a server error, please contact the webmaster 

Error 500
192.168.0.006 
2003年06月30日 00時06分49秒 
Apache/2.0.40 (Red Hat Linux) 

プロバイダ参照:http://help.yahoo.co.jp/help/jp/bb/
サーバのOS:UNIXサーバ
パソコンのOS:WinNT系
エディタ:
FTPソフト:
サーバ移転:していない
改造:(未選択) 改造前不動
CGI習熟度:expert

回答者 やまだ  [削除]  投稿日 7/15(火) 01:57:26
Directory DirectiveのOptionsにExecCGIを追加すると可能かと。
質問者 野田  [削除]  投稿日 7/15(火) 22:26:53
やまださん,回答有難う御座います。多分に私自身の誤解があるかも知れませんが、初期状態でExecCGIは設定されていると思います。ちなみに初期状態と試した記録は下記の通りです。何か抜けているところがあるのでしょうか?

初期ディレクティブ
<Directory "/var/www/cgi-bin">
	Options  Includes ExecCGI 
	AllowOverride 
      Options None
	Order allow,deny
	Allow from all
</Directory>

Option NoneをコメントアウトしOption Allを追加
<Directory "/var/www/cgi-bin">
	Options  Includes ExecCGI 
	AllowOverride None
#     Options None
	Options All
	Order allow,deny
	Allow from all
</Directory>
  Options Indexes FollowSymLinks Includes   ----   追記

ここまでの設定でCGI、SSIは正常に動作します。


Cを認識させるため行った試行錯誤は下記の通りです。
もちろん結果は全てNGです。

1.AllowOverride のNoneを削除
<Directory "/var/www/cgi-bin">
	Options  Includes ExecCGI 
	AllowOverride 
#     Options None
	Options All
	Order allow,deny
	Allow from all
</Directory>

2.Options Includes ExecCGIをAllowOverride の次に移動。
<Directory "/var/www/cgi-bin"> 
	AllowOverride 
	Options Includes ExecCGI
#     Options None
	Options All
	Order allow,deny
	Allow from all
</Directory>

3.AllowOverrideをコメントアウト
<Directory "/var/www/cgi-bin"> 
#	AllowOverride 
	Options  Includes ExecCGI
#     Options None
	Options All
	Order allow,deny
	Allow from all
</Directory>


4.FollowSymlinksを追記
<Directory "/var/www/cgi-bin"> 
	Options ExecCGI Includes FollowSymlinks
	AllowOverride 
#     Options None
	Options All
	Order allow,deny
	Allow from all
</Directory>

その他色々試しましたが論理的でないため省略します。

返信(回答)する

 


Web裏技