简体   繁体   English

找不到perl / cgi脚本错误404 apache2

[英]perl/cgi script not found error 404 apache2

I have a perl script in /var/cgi-bin directory which executes normally with the url: 我在/ var / cgi-bin目录中有一个perl脚本,该脚本通常使用url执行:

localhost/cgi-bin/filename.pl 本地主机/cgi-bin/filename.pl

but when i call the same file through a html file the loaclhost server return a 404 not found error. 但是当我通过html文件调用同一文件时,loaclhost服务器返回404 not found错误。

code: html file: 代码: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 file: 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;

the apache2 000-default.conf: apache2 000-default.conf:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
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>

Your form action is "filename.pl". 您的表单操作是“ filename.pl”。 That means the web server will look for "filename.pl" in the same directory as the HTML page containing the form. 这意味着Web服务器将在与包含表单的HTML页面相同的目录中查找“ filename.pl”。 And that's not where it it. 那不是那里。 You probably want the full path. 您可能想要完整的路径。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM