• 締切済み

/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>

みんなの回答

  • php504
  • ベストアンサー率42% (926/2160)
回答No.1

ScriptAlias を使うとそのディレクトリ内のファイルはすべてスクリプトとして扱われますので画像ファイルやhtmlテキストファイルは読み出せなくなります。 すでにExecCGIの指定がされているようなので(ScriptAliasの場合は必要ない) ScriptAlias /cgi-bin/ "F:/cgi-bin/" を Alias /cgi-bin/ "F:/cgi-bin/" に変えれば良いでしょう AddHandler cgi-script .cgi も必要になります(Apache2)

kahata
質問者

お礼

ありがとうございました。早速試してうまくいきました。

関連するQ&A

  • 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の中身が見えないのかわかりません。 よろしくおねがいします。

  • 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ファイルも表示できるように許可を 出したいのですが、どのように設定すればよろしいのでしょうか?

  • 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> 以上、どうかよろしくお願いいたします。

  • 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/"をコメントアウトしました。もしよろしければご指導のほどよろしくおねがいします。

  • 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
  • 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
  • httpd.confのDirectoryIndexを記述しても、DocumentRoot直下のindex.htmlが表示されない

    初歩的な質問でしたら、申し訳ありません。。。 Apacheを勉強し始めの初心者です。 Apache2.2をローカル(windowsXP)にインストールし、httpd.confの設定を、以下のようにしました。 -------------------------------------- DocumentRoot "E:/web" <Directory /> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <Directory "E:/web"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> -------------------------------------- ブラウザにて、「http://local/」にアクセスしても、index.htmlが表示されず、HTTP400のエラーが返ってきてしまいます。 (E:/web配下には、index.htmlが確実に存在します。。) なのですが、E:/web/test 配下に、E:/web直下と同じindex.htmlを置き、「http://local/test/」にアクセスすると、正常にindex.htmlが表示されます。 httpd.confに、VirtualHostの設定はしていません。 色々と調査し、試行錯誤してみたのですが、理由がわからずにいます。。。 DocumentRoot直下は、DirectoryIndexと関係ないのでしょうか?? 初歩的な質問でしたら、誠に申し訳ありません。。 また、初心者のため、情報が足りない事があるかもしれません。 その時は、がっつりご指摘ください。 環境: Apache2.2 Tomcat5.5

  • apacheのCGI設定

     pc9821にFreeBSD(98)をいれapache1.3を起動させています。cgiはlight.cgiというソフトをつかっています。なかなかcgiがうまくいきません。参考ページには public_html / index.html (トップページ) | +-- bbs / light.cgi [755] | admin.cgi [755] ・・・・(省略) +-- lock [777] / | +-- past [777] / 0001.cgi [666] とかかれていますが、実際に私のサーバーにはpublic_htmlというフォルダは存在していなくて /usr/local/www/cgi-binにbbsというフォルダをつくり あとは上のようにしています。またindex.htmlは/usr/local/www/dataのなかにいれて表示してWebサーバーとしてはたらいています。またapacheの/usr/local/etc/apacheのhttpd.confは 関係ありそうな行だけあげると ServerRoot "/usr/local" DocumentRoot "/usr/local/www/cgi-bin" <Directory "/usr/local/www/cgi-bin/bbs"> Options Indexes FollowSymLinks MultiViews <location "/cgi-bin/"> Options ExecCGI AllowOverride AuthConfig Limit Order allow ,deny Allow from all </Location> <IfModule mod_mime.c> TypesConfig /usr/local/etc/apache/mime.types ADDHandler cgi-script .cgi </IfModule> ScriptAlias /cgi-bin/ "/usr/local/www/cgi-bin/" <Directory "/usr/local/www/cgi-bin/bbs"> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> AddHandler cgi-script .cgi どこがおかしいのかおしえていただけないでしょうか?

    • ベストアンサー
    • CGI
  • httpd.confを添削してください!!(長文)

    こんにちわ いろいろと調べながらhttpd.confを自分の理想の動作を得るたねに設定したつもりです。 添削をお願いします。 /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ DocumentRoot /var/www/html <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory "/var/www/html"> #←home Options FollowSymLinks Includes AllowOverride All Order allow,deny Allow from all </Directory> #.htaccessを許可、cgiは不可、ssiは許可、シンボリックリンク許可 Order~略 <IfModule mod_userdir.c> UserDir public_html </IfModule> <Directory /home/*/public_html> AllowOverride AuthConfig Limit Options +ExecCGI +Includes </Directory> #ユーザー領域では.htaccessで認証、アクセス元などで制御の許可。 それ以外は不可。 homeでcgiが不可ですがここでは許可したいので+を付けた。 <Directory "/var/www/cgi-bin"> AllowOverride All Options ExecCGI Order allow,deny Allow from all AddHandler image .gif .jpg AddHandler text/html .htm .html </Directory> /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ こんな感じなんですがどこかおかしいでしょうか?

  • CGIの設定

    いつもお世話になっております。 各バーチャルドメイン内でCGIを動作させるためにApacheの設定を したのですが、「ページが表示されません」と出てしまいます。 (バーチャルドメインの設定も完了していて、HTMLファイル、PHPファイルは正常に動作しています。) よろしくご教示お願いいたします。 /etc/httpd/conf/httpd.conf -------------------------------------------------- ScriptAliasMatch /~(..*)/cgi-bin/(.*) /home/$1/cgi-bin/$2 <Directory "/home/*/cgi-bin"> AllowOverride None # Options None Options ExecCGI Order allow,deny Allow from all </Directory> (1) ↓にファイルをアップロード   パーミッションは「755」に設定してあります。   /home/ユーザ名/cgi-bin/count.cgi (2) ブラウザから↓のURLでアクセス   http://バーチャルドメイン/cgi-bin/count.cgi <環境> Red Hat Enterprise Linux 5 Apache:2.2.3