Apache环境下 如何运行Perl写的cgi

 
运行环境:
 Windows XP, WampServer, Active Perl 5.6
安装完毕,
 用记事本打开httpd.conf文件,
1.搜索cgi-bin,找到
ScriptAlias /cgi-bin/ "d:/wamp/Apache2/cgi-bin/删除前面的#号,这是存放cgi文件的路径
2. 搜索AddHandler  找到AddHandler  cgi-script .cgi ,这是定义可执行cgi文件扩展名,可以把.cgi 改为 .pl 或加上”, .pl” ,成为“ AddHandler cgi-script .pl ,.cgi“这样两个后缀都可以用了。
 
3.更改Options、Allow Override的参数为All。
改完之后象这样:
#
# "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "d:/wamp/apache2/cgi-bin">
    AllowOverride all
    Options all
    Order allow,deny
    Allow from all
</Directory>
 
4.建立文件 test.pl , 内容如下:
#!d:/Perl/bin/perl   
##    写成!d:/Perl/bin/perl.exe也可以
## 注意,如果没有第一行或写错,apache找不到perl解释器
## ,会出现500 Internal Server     
print "Content-type:text/html/n/n";
print "CGI执行成功!";
 
 
 
 在www目录下,建立一个html文件,内容如下:
<a href="http://localhost/cgi-bin/test.pl" > CGI</a>
5. 重新启动apache server,然后在浏览器打开这个文件,提示 “CGI执行成功!”

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值