【发布时间】:2017-02-25 03:42:08
【问题描述】:
我正在尝试用 PERL 做一个简单的测试。我编写了 input.html 并将其放在 hdocs 文件夹中,并将 output.cgi 放在 cgi-bin 中。两者都在 XAMPP 文件夹中,使用 mac。这也是在使用 apache。
HTML 文件
<!doctype html>
<html lang="en">
<body>
<form action="/cgi-bin/output.cgi" method="post">
Enter Fahrenheit: <input type="text" name="fahrenheit" /><br />
Enter Distance in Miles: <input type="text" name="distance" /><br />
<input type="submit" value="Convert!" />
</form>
这是当用户按下“转换”时应该显示的 CGI 文件
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
#### read form data
my $fahrenheit = param('fahrenheit');
my $distance = param('distance');
#### do the math
my $celcius = ($fahrenheit * 18.8) + 32;
my $kilometers = $distance * 1.60934;
#### display results
print "<h2>Assignment 3</h2>";
print "Conversion: <br />";
printf "Celcius: \$%.2f <br />", $celcius;
printf "Kilometers: \$%.2f <br />", $kilometers;
这是Apache的错误日志
Marker - Oct 15, 2016, 5:56:38 PM
[Sat Oct 15 17:56:41.765457 2016] [cgi:error] [pid 3086] [client ::1:50144] AH01215: (13)Permission denied: exec of '/Applications/XAMPP/xamppfiles/cgi-bin/output.cgi' failed: /Applications/XAMPP/xamppfiles/cgi-bin/output.cgi, referer: http://localhost/input.html
[Sat Oct 15 17:56:41.765785 2016] [cgi:error] [pid 3086] [client ::1:50144] End of script output before headers: output.cgi, referer: http://localhost/input.html
这就是 localhost 中应该显示 output.cgi 的页面的样子
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
End of script output before headers: output.cgi
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.23 (Unix) OpenSSL/1.0.2h PHP/5.6.24 mod_perl/2.0.8-dev Perl/v5.16.3
【问题讨论】:
标签: apache perl permissions xampp cgi