ブラウザで呼び出すとエラーに

このQ&Aのポイント
  • CGIプログラムを書きたくてゼロから勉強をはじめた者です。プログラムの経験はまったく無いですが、Perlを勉強したいと思っています。使用するのは自宅のMac(OS10.4)です。
  • 1行目に#!/usr/bin/Perlとパスを書き、それをCGI-Executablesフォルダの中に「go.cgi」という名前で保存しました。次にTerminalにてパーミッション設定。chmod 755 /Library/WebServer/CGI-Executables/go.cgiと書きました。
  • 心配なのでケーブルを抜いてからパーソナルWeb共有を開始した後、http://以降localhost/cgi-bin/go.cgiあるいは127.0.0.1/cgi-bin/go.cgiでブラウザから呼び出してみたのですが、次のようなエラーが表示されてしまいます。The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.解説本やネットの情報を組み合わせてやってみたのですが、間違っている箇所がありましたらご教授ください。よろしくお願いします。
回答を見る
  • ベストアンサー

ブラウザで呼び出すとエラーに

CGIプログラムを書きたくてゼロから勉強をはじめた者です。 プログラムの経験はまったく無いですが、Perlを勉強したいと思っています。使用するのは自宅のMac(OS10.4)です。 1行目に#!/usr/bin/Perlとパスを書き、それをCGI-Executablesフォルダの中に「go.cgi」という名前で保存しました。 次にTerminalにてパーミッション設定。 chmod 755 /Library/WebServer/CGI-Executables/go.cgi と書きました。 心配なのでケーブルを抜いてからパーソナルWeb共有を開始した後、http://以降localhost/cgi-bin/go.cgi あるいは127.0.0.1/cgi-bin/go.cgiでブラウザから呼び出してみたのですが、次のようなエラーが表示されてしまいます。 The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. 解説本やネットの情報を組み合わせてやってみたのですが、間違っている箇所がありましたらご教授ください。 よろしくお願いします。

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

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

  • ベストアンサー
  • diszo
  • ベストアンサー率78% (32/41)
回答No.1

まず、このエラーは500番のInternal Server Errorになります。 内部エラーですね。 WebサーバがCGIを動作しようとしたときに、 エラーになってしまいクライアントに情報を返せないときにでるエラーです。 どのようなCGIを動かしているかわかりませんので回答はしかねますが、 以下のようなことを怪しんでみてください。 ・perlのスクリプトは正しいか  #Terminalは使えているようですので、./go.cgiなどとして実行してみてください。エラーが出るようでしたら修正する必要があります。 ・パーミッションは正しいか  設定されているようですけど、Perlの中から違うPerlのスクリプトを呼び出していて、そのスクリプトのパーミッションが正しくないとか ・HTTPヘッダは書かれていますか  一番先頭に、以下のような文を表示していますか?  print "Content-Type: text/plain\n\n";  #私も結構忘れます。。。  #詳しいことは、参考URL等をお読みください。 お分かりかもしれませんが、 初めてということですので、参考になればということで、 PerlでCGI書く場合は、以下のような手順でやっています。 1.Terminalから実行して文法エラーがないか確認する 2.Webサーバに置いて、パーミッションをいじってから   ブラウザで確認する わからない場合は、ネットで検索すれば、かなりの数の情報を得られると思います。

参考URL:
http://www.tohoho-web.com/ex/http.htm
ameto8
質問者

お礼

回答ありがとうございます! お礼が遅くなりすみませんでした。 実はプログラムとして書いたのはPerlパス1行だけだったんです。 HTTPヘッダ書いてなかったです・・ 忘れていたんじゃなくてそれでいいと思っていたので^^; もしかして(!)と思ってやってみたら上手くいきました。 それからPerlの手順も参考にさせていただきました。 間違っていなかったので、すごく自信になりました。どうもありがとうございます^^ ただ構文チェックのところでつまづいているので、そのことをMacintoshカテゴリで質問させていただこうかと考えてます。

関連するQ&A

  • CGI プログラムエラーの解決法を教えてください。

    CGIの勉強をしている初心者です。 CGI プログラムを起動させると、 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.・・・・・ となってしまい、CGIがブラウザに表示されません。 どなたか解決法をご存知の方、教えてください。 (使用PCは、MacOSX(10.6.8)です。) 行った手順 1. Apacheの動作確認 [Machintosh HD]→[アプリケーション]→[システム環境設定] → 共有・アイコン → 「Web 共有」にチェックを入れる。 2. test.cgiを設置 設置場所 [Machintosh HD]→[ライブラリ]→[WebServer] → 「CGI-Executables」にtest.cgiを設置 test.cgiは下記 #!/usr/bin/perl print "Content-type: text/html\n\n"; print "<HTML>\n"; print "<HEAD><TITLE>CGI TEST</TITLE></HEAD>\n"; print "<BODY>ちわ!世界。</BODY>\n"; print "</HTML>\n"; __END__ 3.ターミナルでCGIプログラムに実行権をつける chmod 755 /Library/Webserver/CGI-Executables/test.cgi 4.ブラウザに「http://localhost/cgi-bin/test.cgi」を入力 最初に表示した「Internal Server Error」になってしまう。 ちなみに・・・ 1. ファイルに実行権限が付いているか確認したところ、下記のようになりました。 ls -la /Library/WebServer/CGI-Executables/test.cgi -rwxr-xr-x@ 1 taka staff 188 2. Syntaxを確認したところ、下記のようになりました。 perl -c /Library/Webserver/CGI-Executables/test.cgi /Library/Webserver/CGI-Executables/test.cgi syntax OK 3. ターミナルにて、which perlを確認したところ、下記のようにまりました。 /usr/bin/perl 4. tail -f /private/var/log/apache2/error_logにてApacheのエラーログを確認をしたところ、下記のようになりました。 [Thu Sep 22 22:31:17 2011] [error] [client 127.0.0.1] (8)Exec format error: exec of '/Library/WebServer/CGI-Executables/test.cgi' failed [Thu Sep 22 22:31:17 2011] [error] [client 127.0.0.1] Premature end of script headers: test.cgi エラーログの見方、解決法もわからない初心者です。 どなたか解決法をご存知のかた、教えてください。 どうぞよろしくお願いいたします。

    • 締切済み
    • CGI
  • PerlでFILEを埋め込もうとするとエラー

    Perlでアクセスカウンターを作ろうと思っています。 そこでファイルオープンを勉強し、 CGIプログラムを実行しようとしたところ、 エラーが起こりました。↓ Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, ********@*********(伏せてあります) and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. ------------------------------------------ Apache/2.0.55 (Win32) Server at 127.0.0.1 Port 80 ソースを見てもおかしい所は見当たりません…↓ #! c:/perl/bin/perl open(FILE, "./sample.txt"); @data = <FILE>; close (FILE); print <<END; Content-type: text/html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>sample</title> </head> <body> <p>$data[0]</p> <p>$data[1]</p> <p>$data[2]</p> </body> </html> END サーバーはApacheを使っています。 原因がわかったら教えてください。 よろしくお願いします。

    • ベストアンサー
    • Perl
  • Apacheの設定方法を教えてください

    cgi-binフォルダの、どのCGIファイル階層のHTMLファイルにもアクセスすることが出来ません。 また、画像ファイルにもアクセスできません。 CGIファイルだけで動くプログラムはそのままでいいのですが、HTMLや画像ファイルが必要な場合はエラーとなって何も出来なくなってしまってます。 アパッチのどの設定が制限しているのでしょうか? エラーは以下の通りでした。 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, ???@????.or.jp and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.

  • 教えてgooサーバーエラー

    すみません 教えてgooでInternal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, root@ask01.goo.ne.jp and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. という表記が出てきます。 よく意味が分からないのですが、どのように対処すればよいのでしょうか よろしくお願いします

  • Internal Server Errorについて

    いつもご丁寧なご回答本当にありがとうございます。 postmailをサーバーに転送し、メールの送信を試してみたところ下記のエラーが出てしまいました。 パーミッションの確認、センドメールのパス、CGIのパス、メールアドレスの確認もしましたが、間違っていないようです。 サーバーはセンドメール自作CGIが使えるサーバーです。 入力ソースのformもpostmail-cgiで記載しています。 良い、アドバイスがありましたら是非、宜しくお願いいたします。 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, info@stepserver.jp and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. -------------------------------------------------------------------------------- Apache/1.3.41 Server at sss002.kix.ad.jp Port 443

    • 締切済み
    • CGI
  • 500 Internal Server Error

    http://iboard3.to/ で始まるURLのどのサイトでも 500 Internal Server Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, info@iboard2.to and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. と表示され、見ることができません。 どうしたらよいですか?

  • あるHPにアクセスしてのエラー

    以下のエラーが出ました。これは、私の方のせいですかね?いきなり英語でエラーメッセージが出ても・・・ Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, あるHPのアドレス and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. どうしたらいいのでしょうか?

  • Internal Server Error???

    こんにちは。 CGIを作ったのですが、 【Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@life-web.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. 】 と言うエラーが出て動きません. もう一つ同じようなcgiを作ったのですが、そちらは普通に動きます.すみませんが、このエラーの場合はどうしたらいいですか? CGIはメールフォームからのメールを送信するものです。

    • ベストアンサー
    • CGI
  • fedoraにcgi

    mkdir でディレクトリを作って vi who cgiを作って 内容は #!/usr/bin/perl print "Content-type: text/html\n\n"; print "<html><body>\n"; print "<pre>"; print 'whoami'; print "</pre>"; print "</body></html>"; なのですが、 ブラウザでテストすると Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, ****@hotmail.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/1.3.29 Server at test.modena.com Port 81 Please contact the server administrator, ****@hotmail.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache/1.3.29 Server at test.modena.com Port 81 という風に表示されます。 設定が違っているのでしょうか?

  • 内部サーバーエラーについて

    HPを作っていたとき内部サーバーエラーと出ました。 サーバーはhttp://www.pf-x.net/ エラーメッセージは、 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, w@pf-x.net and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. やったことは、エラーページを製作して、 .htaccessを入れたらだめになりました。 どういう意味か、また、対処法を教えてください。

専門家に質問してみよう