在Apache服务器中运行CGI程序的方法

关于apache与CGI在这里就不解释了.
1、apache下载地址:http://www.apache.org,下面以2.0.63为例介绍运行CGI程序的配置。
2、下载Windows下的Perl解释器ActivePerl,官方网站:http://www.activestate.com/,最新版本ActivePerl-    5.10.0.1003,假设安装路径为c:\Perl。

3、修改apache的配置文件httpd.conf:


  AllowOverride None
  Options None
  Order allow,deny
  Allow from all

#AddHandler cgi-script .cgi

改为:


  AllowOverride None
  Options ExecCGI
  Order allow,deny
  Allow from all

AddHandler cgi-script .cgi .pl

4、编写perl脚本程序hello.pl

#!C:\Perl\bin\perl.exe
print "content-type: text/html","\n\n";
print "","\n";
print "","\n";
print "Perl","\n";
print "","\n";
print "","\n";
print "

Hello World

","\n"; print "","\n"; print "","\n";

将程序拷贝到apache安装目录下cgi-bin文件夹下.
5、启动apache服务器,打开浏览器,输入http://localhost/cgi-bin/hello.pl
结果如下:

在Apache服务器中运行CGI程序的方法_第1张图片

你可能感兴趣的:(在Apache服务器中运行CGI程序的方法)