+ -
当前位置:首页 → 问答吧 → CGI程序运行时浏览器里没直接显示,显示下载文件提示界面

CGI程序运行时浏览器里没直接显示,显示下载文件提示界面

时间:2011-06-28

来源:互联网

RT,测试perl写CGI程序环境搭建是否完好,发现浏览器里输入程序名里带上后缀.pl就出现题目里的那个问题。。如果把cgi-bin里的文件名后缀去掉,再在浏览器里输入才可以正常显示,why??


目前httpd.conf的配置
  1. # Add perlscript extensions like cgi, pl, plx .. etc
  2. AddHandler cgi-script .cgi .pl

  3. #Add "+ExecCGI" to the options list in root directory
  4. <Directory />
  5.   Options FollowSymLinks +ExecCGI
  6.   AllowOverride None
  7. </Directory>


  8. <Directory "D:/Apache/cgi-bin">
  9.     AllowOverride None
  10.     Options +ExecCGI
  11.     Order allow,deny
  12.     Allow from all
  13. </Directory>

  14. #
  15. # ScriptAlias: This controls which directories contain server scripts.
  16. # ScriptAliases are essentially the same as Aliases, except that
  17. # documents in the target directory are treated as applications and
  18. # run by the server when requested rather than as documents sent to the
  19. # client.  The same rules about trailing "/" apply to ScriptAlias
  20. # directives as to Alias.
  21. #
  22. ScriptAlias /cgi-bin/ "D:/Apache/cgi-bin/"
复制代码
perl的版本:v5.8.8
系统平台p

测试例子: printenv.pl
  1. #!c:/perl/bin/perl.exe
  2. ##
  3. ##  printenv -- demo CGI program which just prints its environment
  4. ##

  5. print "Content-type: text/plain; charset=iso-8859-1\n\n";
  6. foreach $var (sort(keys(%ENV))) {
  7.     $val = $ENV{$var};
  8.     $val =~ s|\n|\\n|g;
  9.     $val =~ s|"|\\"|g;
  10.     print "${var}=\"${val}\"\n";
  11. }
复制代码

作者: Cu_fans   发布时间: 2011-06-28

改名.cgi

作者: RE_HASH   发布时间: 2011-06-28