2016-11-17 13 views
0

私は、URLで正常に実行されるの/ var /のcgi-binディレクトリ内のperlスクリプトを持っている:のperl/cgiスクリプトがエラー404 apache2のを発見していない

はlocalhost /のcgi-binに/ filename.pl

をが、同じファイルをhtmlファイルで呼び出すと、loaclhostサーバーは404エラーを返しません。

コード: htmlファイル:

<?xml version="1.0"encoding="utf-8"?> 
<html> 
      <head> 
          <title>light bulbsr form</title> 
      </head> 
      <body> 

<form action="/cgi-bin/bulbs.pl" method="POST"> 

user name<input type="text" name="myname" size="30"/><br> 

select the items:<br> 

<input type="checkbox" name="b" value="2.39" /> four100 watt light bulbs </br> 
<input type="checkbox" name="b" value="4.29"> eight 100 watt light bulbs </br> 
<input type="checkbox" name="b" value="3.95"> four 100 watt long life bulbs </br> 
<input type="checkbox" name="b" value="7.49"> eight100 watt long life bulbs </br> 

Select the mode of the payment:</br> 

<input type ="radio" name="paymode" value="visa" checked="checked"/>Visa<br> 
<input type ="radio" name="paymode" value="Master card"/>Master card<br> 
<input type ="radio" name="paymode" value="Discover"/>Discover<br> 

          <input type="submit" value="submit order"/> 
          <input type="reset" value="Clear the form"/> 
      </body> 
</html> 

perlのファイル:

#!/usr/bin/perl 
use CGI qw(:standard); 
use strict; 


print header(),start_html ("Bill "); 
print p("The total cost:0");br(); 
print end_html; 

のapache2 000-は、default.conf:

<VirtualHost *:80> 
ServerAdmin [email protected] 
DocumentRoot /var/www/html 
ScriptAlias /cgi-bin/ /var/cgi-bin/ 
    <Directory "/var/cgi-bin/"> 
      AllowOverride None 
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
      Require all granted 
    </Directory> 
ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 
+0

HTMLドキュメントのURLは何ですか? HTMLファイルが 'cgi-bin'ディレクトリにないので、おそらく' cgi-bin/filename.pl'または '/ cgi-bin/filename.pl'が必要です。 – simbabque

+1

私はこれが学習の練習であることを願っています。あなたはこれでクレジットカード番号を手に入れませんか? – simbabque

+0

はい、これは学習の練習です。 Plzヘルプ! –

答えて

0

あなたのフォームアクションが「filename.plです"つまり、Webサーバーはフォームを含むHTMLページと同じディレクトリにある "filename.pl"を探します。そしてそれはどこにあるのではない。おそらく完全なパスが必要です。

<form action="/cgi-bin/filename.pl"> 
+0

は同じ404エラーを表示しています –

+0

詳細を含めるには[編集](http://stackoverflow.com/posts/40654525/edit)をクリックしてください。このフォームを含むHTMLページはどこにありますか?あなたのCGIディレクトリはどこですか? Webサーバーのエラーログにはどのようなエラーがありますか? –

+0

error.logファイルが見つかりませんエラーをログに記録していません –

関連する問題