Windows環境でのCGI設定について

このQ&Aのポイント
  • Windows+ApacheでCGIを設定する際の質問です。c:\webrootというディレクトリをDocumentRootにしてその下にsampleというディレクトリを作成し、そのディレクトリの中にCGIとHTMLを配置したいと考えています。
  • 設定したhttpd.confが正しく動作せず、CGIが実行されないためアドバイスを求めています。
  • 質問者はAliasとScriptAliasの設定を行っており、ディレクトリのOptionsやAllowOverrideも設定しています。しかし、なぜかCGIが実行されない状態です。
回答を見る
  • ベストアンサー

Windows環境でのCGI設定について

Windows+ApacheでCGIを設定する際の質問です。 「c:\webroot」というディレクトリをDocumentRootにして その下に「sample」というディレクトリを作成し、 そのディレクトリの中にCGIとHTMLを配置したいと考えています。 試しにc:\webroot\sample\printenv.cgiというcgiを 配置してhttpd.confを以下の様に設定しましたが、 以下のURLでアクセスしてもCGIは実行されません。 http://localhost/sample/printenv.cgi (※printenv.cgi自体はScriptAliasがcgi-binの状態では   実行されているのは確認しています。) 恐らく設定のいくつかが間違っている為と 思いますのでアドバイスして頂けたら幸いです。 ================================================ Alias /sample/ "C:/webroot/sample/" <Directory "C:/webroot/sample/"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all DirectoryIndex index.htm index.html </Directory> ScriptAlias /sample/ "C:/webroot/sample/" <Directory "C:/webroot/sample"> AllowOverride None Options None Order allow,deny Allow from all </Directory>

  • CGI
  • 回答数1
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
  • anmochi
  • ベストアンサー率65% (1332/2045)
回答No.1

? なぜ エイリアス後にスクリプトエイリアスをしているの? 多分これではエイリアスが有効になって、そのロケーション(/sample)でスクリプトエイリアスをしようとして失敗すると思う。試した事はないけど。  ScriptAliasは消して、OptionsにExecCGIをつけてあげよう。もちろん、「/sample」以下が全てCGI実行可能になってしまう点には気をつけて。 Alias /sample/ "C:/webroot/sample/" <Directory "C:/webroot/sample/"> Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride None Order allow,deny Allow from all DirectoryIndex index.htm index.html </Directory>

veracity
質問者

お礼

ありがとうございます。 ご指摘の通りScriptAliasの設定を修正したところ、 期待した動きを確認する事ができました。

関連するQ&A

  • /cgi-bin/のファイル読み出し

    WindowsXPでApacheをlocalhostで使用しています。 httpd.confを以下のように設定してcgiは問題なく作動していますが、/cgi-bin/に置いた画像やhtmlが読み出せません (すなわちhttp://localhost/cgi-bin/にアクセス出来ず、Forbiddenのエラーが出ます) 今は仕方なく、cgiで使用するファイルや画像をDocumentRoot配下に置いていますが、/cgi-bin/配下のファイルを読み出すhttpd.confの設定を教えて下さい。 DocumentRoot "F:/" <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "F:/"> AllowOverride None Order allow,deny Allow from all </Directory> <IfModule mod_alias.c> ScriptAlias /cgi-bin/ "F:/cgi-bin/" <Directory "F:/cgi-bin"> AllowOverride None Options ExecCGI MultiViews Order allow,deny Allow from all </Directory> </IfModule>

  • cgi-binにアクセスできない

    apache初心者です。 Turbolinux6.0+apache1.3.12でHTTPサーバを試しているのですが、 cgi-binにあるファイルを見ようとするとHTTP 403エラーが出て表示できません。 属性とグループを色々変えてみたんですが、だめでした。 access.confで関係ありそうな所は <Directory /> Options None AllowOverride None order allow,deny allow from all </Directory> <Directory /home/httpd/html> Options Indexes Includes FollowSymLinks AllowOverride None order allow,deny allow from all </Directory> <Directory /home/httpd/cgi-bin> AllowOverride None Options FollowSymlinks ExecCGI order allow,deny allow from all </Directory> としていますが、なぜcgi-binの中身が見えないのかわかりません。 よろしくおねがいします。

  • ApacheのScriptAliasについて

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/ ScriptAlias /cgi-bin/ /home/*/public_html/cgi-bin/ # # "/usr/lib/cgi-bin" could be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory /var/www/cgi-bin/> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> <Directory /home/*/public_html/cgi-bin> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> 何がやりたいかと言うと複数箇所でcgi-binを作ってCGIをうごかせるようにしたいのですが、ScriptAliasは複数指定ってできるのでしょうか? できなければ何かうまい方法はないでしょうか?よろしくお願いしますm(_ _)m

  • Fedora Core1サーバーでCGIが利用できません

    Fedora Core1でwebサーバーを立てたのですが、実行しようとすると「500 Internal Server Error」となってCGIが動きません。 perlへのパスやパーミッションの設定も見直しましたが、どこの設定が間違っているか分からないので、設定方法を教えてもらえないでしょうか? 現在の環境は ホスト名:saba.dyndns.org perlのパス:/usr/local/bin/perl CGIを仕えるようにしたいユーザー:guest CGIを設置するディレクトリ:/home/guest/cgi-bin/ Apacheのバージョンは2.0.49 となっています。 また以下はhttpd.confの抜粋です。 Listen *:80 #ScriptAlias /cgi-bin/ "/var/www/html/" ScriptAlias /cgi-bin/ "/home/guest/public_html/cgi-bin/" AddHandler cgi-script .cgi .pl <Directory "/home/guest/public_html/"> Options ExecCGI AllowOverride None Allow from all Order allow,deny </Directory> <Directory /home/*/public_html> AllowOverride FileInfo AuthConfig Limit Options Includes ExecCGI FollowSymLinks <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory> 長文失礼しました。

  • cgi-binディレクトリ内のhtmlを有効にしたい

    度々お騒がせしております。 本日は、Apacheの設定について 伺いたく投稿させていただきました。 apacheの設定を終え、 一通り動作するようにできたのですが、 cgi-binディレクトリに置いたhtmlや jpg,gifといったcgi以外のファイルが 表示されません。 httpd.confによる cgi-binディレクトリの設定でどうにかなるものと思い、 色々調べてみたのですが、 いまいち設定方法がわかりません。 以下、私の環境です。 Apacche 1.3.20 htmlディレクトリ /var/www/html/ (775) cgi-binディレクトリ /var/www/html/cgi-bin/ (775) 現在のcgi-binディレクトリの設定 ScriptAlias /cgi-bin/ "/var/www/html/cgi-bin/" <Directory "/var/www/cgi-bin"> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> 以上、どうかよろしくお願いいたします。

  • cgi-bin配下のファイルに読込許可を!

    最近、Apache2を使い始めたばかりで設定がよくわかりません。 Apacheの設定ファイルで、httpd.confというファイルがありますが、その中で、 ScriptAlias /cgi-bin/ "C:/Apache2/htdocs/cgi-bin/" <Directory "C:/Apache2/htdocs/cgi-bin"> AllowOverride None Options All Order allow,deny Allow from all </Directory> と記述して"C:/Apache2/htdocs/cgi-bin"配下にあるファイルに CGIが動作するように許可しました。 しかし、これだと逆に"C:/Apache2/htdocs/cgi-bin"配下にある HTMLファイル(.htm等)が読み込めなくなってしまいます。 cgi-bin配下にあるhtmlファイルも表示できるように許可を 出したいのですが、どのように設定すればよろしいのでしょうか?

  • Apache(Ver 2.4.4)の設定のエラー

    おはようござます。 Win VISTAです。 Apache(Ver 2.4.4)の設定をしています。(XAMPP 1.8.3) いろいろと参考書を見ながら、意味もわからずhttpdファイル(C:\xampp\apache\conf\httpd)のセキュリティの設定変更をしていますが、 「Access forbidden! 要求されたディレクトリへのアクセス権限がありません。 インデックスドキュメントが存在しないか、 ディレクトリの読み込みが許可されていません。 サーバーの障害と思われる場合は、ウェブ管理者までご連絡ください。」 というエラーが出て困っています。 セキュリティの設定の変更までは、正常にインストールされているとの確認画面が出ていましたので、この変更のミスが原因としか考えられません。 何とど宜しくお願いします。 ============================================================= httpdファイル(C:\xampp\apache\conf\httpd)の内容(変更後です) <変更前の内容はバックアップをとっていませんのでわかりません・・・・> <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "C:/xampp/htdocs" <Directory "C:/xampp/htdocs"> ・ ・ ・ # Order allow,deny # Allow from all Order deny,allow Deny from All Allow from localhost 127.0.0.1 # AllowOverride All ・ ・ # Require all granted </Directory> ・ ・ ・ <Directory "C:/xampp/cgi-bin"> AllowOverride None Options None # Order allow,deny # Allow from all Order deny,allow Deny from All Allow from localhost 127.0.0.1 # Require all granted </Directory> ============================================================= (C:\xampp\apache\conf\extra\httpd-xampp)<このファイルは全く書き換えていません。> <Directory "C:/xampp/php"> AllowOverride None Options None Require all denied <Files "php-cgi.exe"> Require all granted </Files> </Directory> ・ ・ ・ <Directory "C:/xampp/cgi-bin"> <FilesMatch "\.php$"> SetHandler cgi-script </FilesMatch> <FilesMatch "\.phps$"> SetHandler None </FilesMatch> </Directory> <Directory "C:/xampp/htdocs/xampp"> <IfModule php5_module> <Files "status.php"> php_admin_flag safe_mode off </Files> </IfModule> AllowOverride AuthConfig </Directory> </Directory> Alias /licenses "C:/xampp/licenses/" <Directory "C:/xampp/licenses"> Options +Indexes <IfModule autoindex_color_module> ・ ・ </IfModule> Require all granted </Directory> =============================================================

    • ベストアンサー
    • PHP
  • apacheとCGIの設定(httpd.conf)について

    Apache/1.3.26を使用しています。 CGIの定義の中に Alias /cgi-bin/ /usr/lib/cgi-bin <Directory /usr/lib/cgi-bin/> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> があるのですがこれは何を定義しているのでしょうか? また、ある指定のフォルダ /var/www/cgi-bin だけ CGI設置可能にするにはどうすればよいでしょうか?

  • apacheのScriptAliasの記述について

    どなたか,ご教授いただければ幸いです。 WindowsXp Proでapacheを動かしています。次の設定で,cgiはうまく動作していました。 --- <IfModule alias_module> ScriptAlias /cgi-bin/ \"C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/\" </IfModule> <Directory \"C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin\"> AllowOverride None Options ExecCGI Order allow,deny Allow from all AddHandler image/gif .gif AddHandler image/jpeg .jpg </Directory> --- これに, http://www.miloweb.net/win/server/apache.html を参考にして,各ユーザーフォルダでcgiが実行できるようにしようと,次のようにしました。 --- <IfModule alias_module> ScriptAlias /cgi-bin/ \"C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/\" ScriptAlias /cgi/ \"C:/www/users/*/cgi/\" </IfModule> <Directory \"C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin\"> AllowOverride None Options ExecCGI Order allow,deny Allow from all AddHandler image/gif .gif AddHandler image/jpeg .jpg </Directory> <IfModule mod_userdir.c> UserDir \"C:/www/users/*/\" </IfModule> <Directory \"C:/www/users/*/cgi/\"> AllowOverride None Options ExecCGI Order allow,deny Allow from all AddHandler image/gif .gif AddHandler image/jpeg .jp </Directory> --- その結果, http://localhost/~user/ としてuserのホームページにアクセスできるようになったのですが, cgiについては, http://localhost/~user/cgi/・・・ としてもアクセスできません。どなたか原因をご教授いただけないでしょうか。 ScriptAlias /cgi-bin/ \"C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/\" ScriptAlias /cgi/ \"C:/www/users/*/cgi/\" の行を入れ替えると,\"C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/\"においてあるcgiが実行できなくなります。ScriptAliasは1行目しか有効でないようにも見えるのですが,上に書いた参考URLではできているようなので,戸惑っています。

  • Redhat9のHTTPDでCGIがつかえない

    まずやりたい事はユーザーごとにWEBができるようにして、CGIをpublic_html以下のどこにでもCGIが使えるようにしたい思っています。 いろんなサイトを見てhttpd.confをいじってますが、どうしてもCGIを実行しても500エラーがでます。perlの場所はあっているんですが。 httpd.confのいじった所は、 <IfModule mod_userdir.c> UserDir public_html </IfModule> と <Directory /home/*/public_html> AllowOverride FileInfo AuthConfig Limit Options IncludesNoExec ExecCGI FollowSymLinks <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory> と ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"をコメントアウトしました。もしよろしければご指導のほどよろしくおねがいします。

専門家に質問してみよう