【求助】Apache2048測試CGI的環境



贊助商連結


green
2003-12-26, 04:19 PM
Apache2048測試CGI的環境

於Win2kSP4中進行動態IP架站測試CGI的環境。
No-IP DUC(動態IP轉網域)。
Apache2048。
ActivePerl580806

可以看到Apache預設首頁。
ActivePerl5808060 安裝於C:\usr中。

遂進行修改Apache之httpd.conf修改以利執行。
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"
<Directory "C:/Program Files/Apache Group/Apache2/cgi-bin">
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
亦增設
AddHandler cgi-script .cgi.pl

執行Apache2048之cgi-bin內原有的printenv.pl,有修改其內描述Perl所在路徑為
!/usr/bin/perl或是!c:/usr/bin/perl.exe。

於瀏覽器中輸入 http://localhost/cgi-bin/printenv.pl。
但卻出現500 Internal Server Error錯誤。
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

描述Perl所在路徑的兩種方式都試過,均出現錯誤訊息。

遍尋網路資源仍不得其門而入,請能者釋疑。再次感謝!
=====================================================
printenv.pl之內容
!c:/usr/bin/perl.exe
#!c:/Perl/bin/Perl.exe
##
## printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}

贊助商連結


MiDay
2004-01-26, 02:41 PM
最初由 green 發表
Apache2048測試CGI的環境

於Win2kSP4中進行動態IP架站測試CGI的環境。
No-IP DUC(動態IP轉網域)。
Apache2048。
ActivePerl580806

可以看到Apache預設首頁。
ActivePerl5808060 安裝於C:\usr中。

遂進行修改Apache之httpd.conf修改以利執行。
ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/"
<Directory "C:/Program Files/Apache Group/Apache2/cgi-bin">
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
亦增設
AddHandler cgi-script .cgi.pl

執行Apache2048之cgi-bin內原有的printenv.pl,有修改其內描述Perl所在路徑為
!/usr/bin/perl或是!c:/usr/bin/perl.exe。

於瀏覽器中輸入 http://localhost/cgi-bin/printenv.pl。
但卻出現500 Internal Server Error錯誤。
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

描述Perl所在路徑的兩種方式都試過,均出現錯誤訊息。

遍尋網路資源仍不得其門而入,請能者釋疑。再次感謝!
=====================================================
printenv.pl之內容
!c:/usr/bin/perl.exe
#!c:/Perl/bin/Perl.exe
##
## printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}

您試試看將原先安裝之位子刪除將Apache2直接安裝於C:\下

ScriptAlias /cgi-bin/ "C:/Apache2/cgi-bin/"

#
# "C:/Apache2/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "C:/Apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

其他設定均無須變更..

CGI網頁第一行指向請設為#! /usr/bin/perl即可!
這樣因該可以了吧!

green
2004-01-26, 04:32 PM
謝謝MiDay撥冗回應,個人的疑問。
我將再次依照建議來測試,後續將再動態說明與此帖之中。