Apache 怎么样配置 CGI?

这几天配置web环境中cgi遇到好多问题,求解答


发现错别字 3周前 提问
回答
1
浏览
58
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
回答数量: 1
高级测评师 CISM-WSE CISP-PTS CISD

前提是系统安装好Apache(这里介绍的版本以2.0.63为例),下载一个编译器,这些准备工作干完以后开始配置。

第一步,修改apache的配置文件httpd.conf:

<Directory "D:/Apache Group/Apache2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
#AddHandler cgi-script .cgi
改为:
<Directory "D:/Apache Group/Apache2/cgi-bin">
    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>
AddHandler cgi-script .cgi .pl

第二步,编写perl脚本程序hello.pl

#!C:\Perl\bin\perl.exe
print "content-type: text/html","\n\n";
print "<HTML>","\n";
print "<HEAD>","\n";
print "<TITLE>Perl</TITLE>","\n";
print "</HEAD>","\n";
print "<BODY>","\n";
print "<H1>Hello World</H1>","\n";
print "</BODY>","\n";
print "</HTML>","\n";

将程序拷贝到apache安装目录下cgi-bin文件夹下.
最后一步,启动Apache服务器,打开浏览器输入http://127.0.0.1/cig-bin/hello.pl后页面显示“Hello World”后说明配置成功。

3周前 / 评论